Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <massaction name="listing_massaction">
- <action name="delete">
- <settings>
- <confirm>
- <message translate="true">Delete selected items?</message>
- <title translate="true">Delete items</title>
- </confirm>
- <url path="*/items/MassDelete"/>
- <type>delete</type>
- <label translate="true">Delete</label>
- </settings>
- </action>
- </massaction>
- <?php
- namespace ECDownloadsControllerAdminhtmlItems;
- use MagentoBackendAppAction;
- /**
- * Class MassDelete
- */
- class MassDelete extends MagentoBackendAppAction
- {
- /**
- * @return MagentoBackendModelViewResultRedirect
- */
- public function execute()
- {
- $ids = $this->getRequest()->getParam('downloads_id');
- echo $ids;
- exit;
- if (!is_array($ids) || empty($ids)) {
- echo 'Bad';
- exit;
- $this->messageManager->addError(__('Please select Item.'));
- } else {
- echo 'Good';
- exit;
- try {
- foreach ($ids as $id) {
- $emp = $this->_objectManager->get('ECDownloadsModelDownloads')->load($id);
- $emp->delete();
- }
- $this->messageManager->addSuccess(
- __('A total of %1 record(s) have been deleted.', count($ids))
- );
- } catch (Exception $e) {
- $this->messageManager->addError($e->getMessage());
- }
- }
- return $this->resultRedirectFactory->create()->setPath('downloads/index/items');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement