Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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