I need to implement some bulk actions in the grid. I implement one delete action as follows:
protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('entity_id'); $this->getMassactionBlock()->addItem('delete', array( 'label' => $this->__('Delete'), 'url' => $this->getUrl( '*/*/massDelete'), )); return $this; } In the controller, I process the array and everything works correctly.
But how to make some massive action?
For example, if you do this:
protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('entity_id'); $this->getMassactionBlock()->addItem('delete', array( 'label' => $this->__('Delete'), 'url' => $this->getUrl( '*/*/massDelete'), )); $this->getMassactionBlock()->addItem('submit', array( 'label' => $this->__('Aprove'), 'url' => $this->getUrl( '*/*/massAprove'), )); return $this; } That turns out nonsense. Delete will always be processed.
How can this opportunity be realized?
MassAproveAction code
public function massAproveAction() { $products = $this->getRequest()->getParam('entity_id', null); if (is_array($products) && sizeof($products) > 0){ try{ foreach ($products as $product) { Mage::getModel('catalog/product')->setId($product)->setAprove(1); } }catch (Exception $e){ $this->_getSession()->addError($e->getTraceAsString()); } }else{ $this->_getSession()->addError('Please select product'); } }
Aprovetoapprovewill bemassAprovecorrect tomassAprove- Naumov