69 lines
1.9 KiB
PHP
Executable File
69 lines
1.9 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Copyright © 2015 Magento. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace FME\Banners\Controller\Adminhtml\Index;
|
|
|
|
use Magento\Framework\Controller\ResultFactory;
|
|
use Magento\Backend\App\Action\Context;
|
|
use Magento\Ui\Component\MassAction\Filter;
|
|
use FME\Banners\Model\ResourceModel\Banners\CollectionFactory;
|
|
|
|
/**
|
|
* Class MassDisable
|
|
*/
|
|
class MassStatus extends \Magento\Backend\App\Action
|
|
{
|
|
/**
|
|
* @var Filter
|
|
*/
|
|
protected $filter;
|
|
|
|
/**
|
|
* @var CollectionFactory
|
|
*/
|
|
protected $collectionFactory;
|
|
|
|
/**
|
|
* @param Context $context
|
|
* @param Filter $filter
|
|
* @param CollectionFactory $collectionFactory
|
|
*/
|
|
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
|
|
{
|
|
$this->filter = $filter;
|
|
$this->collectionFactory = $collectionFactory;
|
|
parent::__construct($context);
|
|
}
|
|
|
|
protected function _isAllowed()
|
|
{
|
|
return $this->_authorization->isAllowed('FME_Banners::banners');
|
|
}
|
|
|
|
/**
|
|
* Execute action
|
|
*
|
|
* @return \Magento\Backend\Model\View\Result\Redirect
|
|
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
|
|
*/
|
|
public function execute()
|
|
{
|
|
$status = $this->getRequest()->getParam('status');
|
|
|
|
$collection = $this->filter->getCollection($this->collectionFactory->create());
|
|
|
|
foreach ($collection as $item) {
|
|
$item->setStatus($status);
|
|
$item->save();
|
|
}
|
|
|
|
$this->messageManager->addSuccess(__('A total of %1 record(s) have been changed.', $collection->getSize()));
|
|
|
|
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
|
return $resultRedirect->setPath('*/*/');
|
|
}
|
|
}
|