Skip to content

Instantly share code, notes, and snippets.

@jamby77
Created April 28, 2014 20:10
Show Gist options
  • Save jamby77/11382675 to your computer and use it in GitHub Desktop.
Save jamby77/11382675 to your computer and use it in GitHub Desktop.
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