I need to show only pending order by users I follow this link

They used sales_order_grid_collection_load_before in magento 1, what exact event in magento 2


How to Collect only pending Orders from Order collection and Show for specific users.


Yes, I achieved this Solution via Plugin.


<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
      <plugin name="sales_order_pending" type="Vendor\Module\Plugin\CustomSalesOrderGridCollection" sortOrder="100" />


          <?php namespace Vendor\Module\Plugin;

    use Magento\Framework\Message\ManagerInterface as MessageManager;
    use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as SalesOrderGridCollection;

    class CustomSalesOrderGridCollection
        private $messageManager;
        private $collection;
        protected  $adminSession;
        protected $logger;

        public function __construct(MessageManager $messageManager,
            SalesOrderGridCollection $collection,
            \Magento\Backend\Model\Auth\Session $adminSession,
            \Psr\Log\LoggerInterface $logger
        ) {

            $this->messageManager = $messageManager;
            $this->collection = $collection;
            $this->adminSession = $adminSession;
            $this->logger = $logger;

        public function aroundGetReport(
            \Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory $subject,
            \Closure $proceed,
        ) {
           $current_adminuser =   $this->adminSession->getUser()->getAclRole();
           $this->logger->addDebug("admin user");

           if(12 == $current_adminuser){

             $result = $proceed($requestName);
             if ($requestName == 'sales_order_grid_data_source') {
                 if ($result instanceof $this->collection) {

                     $this->collection->addFieldToFilter('status', array('in' => array('pending')));

            return $this->collection;

After Clear Cache and Login that user, then its will show only pending Order in sale_order_grid.

  • It's working well, but in content->pages grid page page_id column_id not found error showing, when i disable the plugin the content->pages loading without any error – senthil Jun 21 '18 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.