![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/aheadworks/module-csblock/Controller/Adminhtml/Csblock/ |
<?php namespace Aheadworks\Csblock\Controller\Adminhtml\Csblock; use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Product; class MassStatus extends \Aheadworks\Csblock\Controller\Adminhtml\Csblock { protected $_collection; protected $_filter; protected $csblockModelFactory; /** * @param Action\Context $context * @param \Magento\Ui\Component\MassAction\Filter $filter * @param \Aheadworks\Csblock\Model\CsblockFactory $csblockModelFactory * @param \Aheadworks\Csblock\Model\ResourceModel\Csblock\Collection $collection */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Ui\Component\MassAction\Filter $filter, \Aheadworks\Csblock\Model\CsblockFactory $csblockModelFactory, \Aheadworks\Csblock\Model\ResourceModel\Csblock\Collection $collection ) { parent::__construct($context); $this->_collection = $collection; $this->_filter = $filter; $this->csblockModelFactory = $csblockModelFactory; } /** * Update product(s) status action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $this->_collection = $this->_filter->getCollection($this->_collection); $status = (int) $this->getRequest()->getParam('status'); $count = 0; foreach ($this->_collection->getItems() as $csblock) { $csblockModel = $this->csblockModelFactory->create(); $csblockModel->load($csblock->getId()); if ($csblockModel->getId()) { $csblockModel->setStatus($status); $csblockModel->save(); $count++; } } $this->messageManager->addSuccess( __('A total of %1 record(s) have been updated.', $count) ); return $this->resultRedirectFactory->create()->setRefererUrl(); } }