Skip to content

Commit

Permalink
Merge pull request #16 from Smile-SA/feature-787865
Browse files Browse the repository at this point in the history
Add Retailer Grid massAction
  • Loading branch information
Fanny DECLERCK authored Jun 20, 2019
2 parents 6ddcb48 + ff4bae4 commit bf54eb5
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 3 deletions.
55 changes: 55 additions & 0 deletions Controller/Adminhtml/Retailer/MassAllowDelivery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\Retailer\Controller\Adminhtml\Retailer;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Smile\Retailer\Controller\Adminhtml\AbstractRetailer;

/**
* Retailer Adminhtml MassAllowDelivery controller.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
*/
class MassAllowDelivery extends AbstractRetailer implements HttpPostActionInterface
{
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$retailerIds = $this->getRequest()->getParam('selected');
foreach ($retailerIds as $id) {
$model = $this->retailerRepository->get($id);
$model->setData('allow_store_delivery', true);
$this->retailerRepository->save($model);
}

$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been allowed to store delivery.', count($retailerIds))
);

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $resultRedirect->setPath('*/*/');
}
}
54 changes: 54 additions & 0 deletions Controller/Adminhtml/Retailer/MassDelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\Retailer\Controller\Adminhtml\Retailer;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Smile\Retailer\Controller\Adminhtml\AbstractRetailer;

/**
* Retailer Adminhtml MassDelete controller.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
*/
class MassDelete extends AbstractRetailer implements HttpPostActionInterface
{
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$retailerIds = $this->getRequest()->getParam('selected');
foreach ($retailerIds as $id) {
$model = $this->retailerRepository->get($id);
$this->retailerRepository->delete($model);
}

$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been deleted.', count($retailerIds))
);

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $resultRedirect->setPath('*/*/');
}
}
55 changes: 55 additions & 0 deletions Controller/Adminhtml/Retailer/MassDisable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\Retailer\Controller\Adminhtml\Retailer;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Smile\Retailer\Controller\Adminhtml\AbstractRetailer;

/**
* Retailer Adminhtml MassDisable controller.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
*/
class MassDisable extends AbstractRetailer implements HttpPostActionInterface
{
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$retailerIds = $this->getRequest()->getParam('selected');
foreach ($retailerIds as $id) {
$model = $this->retailerRepository->get($id);
$model->setData('is_active', false);
$this->retailerRepository->save($model);
}

$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been disabled.', count($retailerIds))
);

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $resultRedirect->setPath('*/*/');
}
}
55 changes: 55 additions & 0 deletions Controller/Adminhtml/Retailer/MassDisallowDelivery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\Retailer\Controller\Adminhtml\Retailer;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Smile\Retailer\Controller\Adminhtml\AbstractRetailer;

/**
* Retailer Adminhtml MassDisallowDelivery controller.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
*/
class MassDisallowDelivery extends AbstractRetailer implements HttpPostActionInterface
{
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$retailerIds = $this->getRequest()->getParam('selected');
foreach ($retailerIds as $id) {
$model = $this->retailerRepository->get($id);
$model->setData('allow_store_delivery', false);
$this->retailerRepository->save($model);
}

$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been disallowed to store delivery.', count($retailerIds))
);

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $resultRedirect->setPath('*/*/');
}
}
55 changes: 55 additions & 0 deletions Controller/Adminhtml/Retailer/MassEnable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\Retailer\Controller\Adminhtml\Retailer;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Smile\Retailer\Controller\Adminhtml\AbstractRetailer;

/**
* Retailer Adminhtml MassEnable controller.
*
* @category Smile
* @package Smile\Retailer
* @author Fanny DECLERCK <[email protected]>
*/
class MassEnable extends AbstractRetailer implements HttpPostActionInterface
{
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$retailerIds = $this->getRequest()->getParam('selected');
foreach ($retailerIds as $id) {
$model = $this->retailerRepository->get($id);
$model->setData('is_active', true);
$this->retailerRepository->save($model);
}

$this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been enabled.', count($retailerIds))
);

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $resultRedirect->setPath('*/*/');
}
}
2 changes: 1 addition & 1 deletion Model/RetailerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Magento\Framework\Api\SortOrder;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;

use Smile\Retailer\Api\Data\RetailerInterface;
use Smile\Retailer\Api\Data\RetailerSearchResultsInterface;
use Smile\Retailer\Api\RetailerRepositoryInterface;
Expand All @@ -30,6 +29,7 @@
* @category Smile
* @package Smile\Retailer
* @author Romain Ruaud <[email protected]>
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RetailerRepository implements RetailerRepositoryInterface
{
Expand Down
5 changes: 3 additions & 2 deletions etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* @category Smile
* @package Smile\Retailer
* @author Romain Ruaud <[email protected]>
* @copyright 2017 Smile
* @author Fanny DECLERCK <[email protected]>
* @copyright 2019 Smile
* @license Open Software License ("OSL") v. 3.0
*/
-->
Expand All @@ -21,7 +22,7 @@
<resources>
<resource id="Magento_Backend::admin">
<resource id="Smile_Seller::sellers">
<resource id="Smile_Retailer::retailers" title="Manage Retailers"/>
<resource id="Smile_Retailer::retailers" title="Manage Retailers" />
</resource>
</resource>
</resources>
Expand Down
37 changes: 37 additions & 0 deletions view/adminhtml/ui_component/smile_retailer_listing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,43 @@
</argument>
</filterSelect>
</filters>
<massaction name="listing_massaction">
<action name="enable">
<settings>
<url path="smile_retailer/retailer/massEnable"/>
<type>enable</type>
<label translate="true">Enable</label>
</settings>
</action>
<action name="disable">
<settings>
<url path="smile_retailer/retailer/massDisable"/>
<type>disable</type>
<label translate="true">Disable</label>
</settings>
</action>
<action name="allow_delivery">
<settings>
<url path="smile_retailer/retailer/massAllowDelivery"/>
<type>allow_delivery</type>
<label translate="true">Allow delivery</label>
</settings>
</action>
<action name="disallow_delivery">
<settings>
<url path="smile_retailer/retailer/massDisallowDelivery"/>
<type>disallow_delivery</type>
<label translate="true">Disallow delivery</label>
</settings>
</action>
<action name="delete">
<settings>
<url path="smile_retailer/retailer/massDelete"/>
<type>delete</type>
<label translate="true">Delete</label>
</settings>
</action>
</massaction>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="smile_retailer_columns">
Expand Down

0 comments on commit bf54eb5

Please sign in to comment.