This shows you the differences between two versions of the page.
urapidflow:customization:observer [2014/04/29 15:39] jamby77 created |
urapidflow:customization:observer [2014/04/29 15:39] (current) jamby77 |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Sample code for Observer used to add a column to profile on the fly ===== | ||
+ | The following must be part of Magento extension and method should be registered as observer to '' | ||
+ | |||
+ | <file php Observer.php> | ||
+ | <?php | ||
+ | |||
+ | class Unirgy_RfUrlPrice_Model_Observer | ||
+ | { | ||
+ | /** | ||
+ | * @var string | ||
+ | */ | ||
+ | protected $columnName = ' | ||
+ | |||
+ | /** | ||
+ | * @param Varien_Event_Observer $observer | ||
+ | */ | ||
+ | public function urapidflow_profile_action( $observer ) | ||
+ | { | ||
+ | $action | ||
+ | $profile = $observer-> | ||
+ | $proceed = $profile-> | ||
+ | if ( !$proceed ) { | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | switch ( $action ) { | ||
+ | case ' | ||
+ | $columns = $profile-> | ||
+ | foreach ( $columns as $col ) { | ||
+ | if ( $col[ ' | ||
+ | // column present, no need to do anything | ||
+ | return; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $columns[ ] = array( | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | $profile-> | ||
+ | break; | ||
+ | case ' | ||
+ | case ' | ||
+ | $columns = $profile-> | ||
+ | foreach ( $columns as $idx => $col ) { | ||
+ | if ( $col[ ' | ||
+ | unset( $columns[ $idx ] ); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $profile-> | ||
+ | break; | ||
+ | default : | ||
+ | return; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ |