Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Grid.php
Go to the documentation of this file.
1 <?php
8 
10 {
16  public function execute()
17  {
18  if ($this->getRequest()->getParam('_unsubscribe')) {
19  $problems = (array)$this->getRequest()->getParam('problem', []);
20  if (count($problems) > 0) {
21  $collection =
22  $this->_objectManager->create(\Magento\Newsletter\Model\ResourceModel\Problem\Collection::class);
23  $collection->addSubscriberInfo()->addFieldToFilter(
24  $collection->getResource()->getIdFieldName(),
25  ['in' => $problems]
26  )->load();
27 
28  $collection->walk('unsubscribe');
29  }
30 
31  $this->messageManager->addSuccess(__('We unsubscribed the people you identified.'));
32  }
33 
34  if ($this->getRequest()->getParam('_delete')) {
35  $problems = (array)$this->getRequest()->getParam('problem', []);
36  if (count($problems) > 0) {
37  $collection =
38  $this->_objectManager->create(\Magento\Newsletter\Model\ResourceModel\Problem\Collection::class);
39  $collection->addFieldToFilter(
40  $collection->getResource()->getIdFieldName(),
41  ['in' => $problems]
42  )->load();
43  $collection->walk('delete');
44  }
45 
46  $this->messageManager->addSuccess(__('The problems you identified have been deleted.'));
47  }
48  $this->_view->loadLayout(false);
49  $this->_view->getLayout()->getMessagesBlock()->setMessages($this->messageManager->getMessages(true));
50  $this->_view->renderLayout();
51  }
52 }
__()
Definition: __.php:13