Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <massaction name="listing_massaction">
  2. <action name="delete">
  3. <settings>
  4. <confirm>
  5. <message translate="true">Delete selected items?</message>
  6. <title translate="true">Delete items</title>
  7. </confirm>
  8. <url path="*/items/MassDelete"/>
  9. <type>delete</type>
  10. <label translate="true">Delete</label>
  11. </settings>
  12. </action>
  13. </massaction>
  14.  
  15. <?php
  16. namespace ECDownloadsControllerAdminhtmlItems;
  17.  
  18. use MagentoBackendAppAction;
  19.  
  20. /**
  21. * Class MassDelete
  22. */
  23. class MassDelete extends MagentoBackendAppAction
  24. {
  25. /**
  26. * @return MagentoBackendModelViewResultRedirect
  27. */
  28. public function execute()
  29. {
  30. $ids = $this->getRequest()->getParam('downloads_id');
  31. echo $ids;
  32. exit;
  33.  
  34. if (!is_array($ids) || empty($ids)) {
  35. echo 'Bad';
  36. exit;
  37.  
  38. $this->messageManager->addError(__('Please select Item.'));
  39. } else {
  40. echo 'Good';
  41. exit;
  42.  
  43. try {
  44. foreach ($ids as $id) {
  45. $emp = $this->_objectManager->get('ECDownloadsModelDownloads')->load($id);
  46. $emp->delete();
  47. }
  48. $this->messageManager->addSuccess(
  49. __('A total of %1 record(s) have been deleted.', count($ids))
  50. );
  51. } catch (Exception $e) {
  52. $this->messageManager->addError($e->getMessage());
  53. }
  54. }
  55. return $this->resultRedirectFactory->create()->setPath('downloads/index/items');
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement