Created
April 28, 2014 20:10
-
-
Save jamby77/11382675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sample_Model_Observer | |
{ | |
protected $colToAdd = 'colname'; | |
/** | |
* @param Varien_Event_Observer $observer | |
*/ | |
public function urapidflow_profile_action( $observer ) | |
{ | |
$action = $observer->getData( 'action' ); | |
$profile = $observer->getData( 'profile' ); | |
switch ( $action ) { | |
case 'start': | |
$columns = $profile->getColumns(); | |
foreach ( $columns as $col ) { | |
if ( $col[ 'field' ] == $this->colToAdd ) { | |
// column present, no need to do anything | |
return; | |
} | |
} | |
$columns[ ] = array( | |
'field' => $this->colToAdd | |
); | |
$profile->setData( 'columns', $columns ); | |
break; | |
case 'stop': | |
case 'finish': | |
$columns = $profile->getColumns(); | |
foreach ( $columns as $idx => $col ) { | |
if ( $col[ 'field' ] == $this->colToAdd ) { | |
unset( $columns[ $idx ] ); // unset column to avoid saving it in config after profile finishes | |
} | |
} | |
$profile->setData( 'columns', $columns ); | |
break; | |
default : | |
return; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment