public function onCoreBlockAbstractToHtmlBefore($observer) { $block = $observer->getBlock(); $massactionClass = Mage::getConfig()->getBlockClassName('adminhtml/widget_grid_massaction'); $productGridClass = Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_grid'); if ($massactionClass == get_class($block) && ($productGridClass == get_class($block->getParentBlock()) || in_array(get_class($block->getParentBlock()), $this->_irregularGridClasses))) { /*if ($massactionClass == get_class($block) // other way for checking && 'catalog_product' == $block->getRequest()->getControllerName()) {*/ $types = Mage::getStoreConfig('ampaction/general/commands'); if (!$types) { return $this; } $types = explode(',', $types); foreach ($types as $i => $type) { if (strlen($type) > 2) { $command = Amasty_Paction_Model_Command_Abstract::factory($type); $command->addAction($block); } else { // separator $block->addItem('ampaction_separator' . $i, array('label' => '---------------------', 'url' => '')); } } } return $this; }
public function doAction() { $productIds = $this->getRequest()->getParam('product'); $val = trim($this->getRequest()->getParam('ampaction_value')); $commandType = trim($this->getRequest()->getParam('command')); $storeId = (int) $this->getRequest()->getParam('store', 0); $enhanced = $this->getRequest()->getParam('enhanced', 0); try { $command = Amasty_Paction_Model_Command_Abstract::factory($commandType); $success = $command->execute($productIds, $storeId, $val); if ($success) { $this->_getSession()->addSuccess($success); } // show non critical erroes to the user foreach ($command->getErrors() as $err) { $this->_getSession()->addError($err); } } catch (Exception $e) { $this->_getSession()->addError($this->__('Error: %s', $e->getMessage())); } if ($enhanced) { $this->_redirect('enhancedgrid/catalog_product/index', array('store' => $storeId)); } else { $this->_redirect('adminhtml/catalog_product/index', array('store' => $storeId)); } return $this; }
public function handleAmProductGridMassaction($observer) { $grid = $observer->getGrid(); $types = array('', 'addcategory', 'removecategory', '', 'modifyprice', 'modifyspecial', 'addspecial', '', 'relate', 'upsell', 'crosssell', '', 'copyoptions', 'copyattr', 'copyimg', '', 'changeattributeset', '', 'delete'); foreach ($types as $i => $type) { if ($type) { $command = Amasty_Paction_Model_Command_Abstract::factory($type); $command->addAction($grid); } else { // separator $grid->getMassactionBlock()->addItem('ampaction_separator' . $i, array('label' => '---------------------', 'url' => '')); } } return $this; }
public function toOptionArray() { $options = array(); // magento wants at least one option to be selected $options[] = array('value' => '', 'label' => ''); $types = array('', 'addcategory', 'removecategory', 'replacecategory', '', 'modifycost', 'modifyprice', 'modifyspecial', 'addspecial', 'addprice', 'addspecialbycost', '', 'relate', 'upsell', 'crosssell', '', 'unrelate', 'unupsell', 'uncrosssell', '', 'copyoptions', 'copyattr', 'copyimg', 'removeimg', '', 'changeattributeset', '', 'delete', ''); foreach ($types as $i => $type) { if ($type) { $command = Amasty_Paction_Model_Command_Abstract::factory($type); $options[] = array('value' => $type, 'label' => Mage::helper('ampaction')->__($command->getLabel())); } else { $options[] = array('value' => $i, 'label' => '---------------------'); } } return $options; }