Skip to main content
deleted 642 characters in body
Source Link
bestwebdevs
  • 187
  • 2
  • 20

I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }
deleted 21 characters in body
Source Link
bestwebdevs
  • 187
  • 2
  • 20

Solved - Adding Mass Delete Action to the Grid

I'm new to Magento. II have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

Adding Mass Delete Action to the Grid

I'm new to Magento. I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

Solved - Adding Mass Delete Action to the Grid

I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

added 91 characters in body
Source Link
bestwebdevs
  • 187
  • 2
  • 20

I'm new to Magento. I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

I'm new to Magento. I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

I'm new to Magento. I have created a custom module and need to add checkboxes to the grid and be able to delete multiple values with a mass action. Tried to use number of different articles but nothing worked. Can anyone help me to do this or maybe you know a good working article about this?

Here is the code in controller file:

    public function massDeleteAction() {
       $requestIds = $this->getRequest()->getParam('id');
       if(!is_array($requestIds)) {
       Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select reqeust(s)'));
       } else {
       try {
        foreach ($requestIds as $requestId) {
            $RequestData = Mage::getModel('cpstest_productcomment/cps_collection')->load($requestId);                    
            $RequestData->delete();                    
        }
        Mage::getSingleton('adminhtml/session')->addSuccess(
            Mage::helper('adminhtml')->__(
                'Total of %d record(s) were successfully deleted', count($requestIds)
            )
        );
        } catch (Exception $e) {
        Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
        }
        }
        $this->_redirect('*/*/');
        }

And the code in Grid.php

        protected function _prepareMassaction()
        {
         $this->setMassactionIdField('id');
         $this->getMassactionBlock()->setFormFieldName('id');

         $this->getMassactionBlock()->addItem('delete', array(
         'label'    => Mage::helper('adminhtml')->__('Delete'),
         'url'      => $this->getUrl('*/*/massDelete'),
         'confirm'  => Mage::helper('adminhtml')->__('Are you sure?')
         ));

         return $this;
        }

Error After Adding the Codes

Source Link
bestwebdevs
  • 187
  • 2
  • 20
Loading