Question

How would I restrict access to only show completed orders in the admin for one user or role? This employee only needs to see new pending orders, and I don't want this employee to be able to look back through the history of old completed orders. Whenever there is an issue with an order, her supervisor handles it.

Right now she can export the entire order history, because I want her to be able to export pending orders. Ideally I would prevent her from even looking up old orders, but at a minimum I just want to restrict what's shown in the order grid to make it difficult for her to see completed orders. Thanks.

Was it helpful?

Solution

Try creating an admin observer for

In config.xml

<sales_order_grid_collection_load_before>
    <observers>
        <magepal>
            <type>singleton</type>
            <class>magepal/observer</class>
            <method>handleOrderCollectionLoadBefore</method>
        </magepal>
    </observers>
</sales_order_grid_collection_load_before>

In Observer.php

public function handleOrderCollectionLoadBefore($observer) 
{  
    if(userid){
        $collection = $observer->getOrderGridCollection();
        if ($collection){
            //$collection->addFieldToFilter('status', array('in' => array('complete')));
            $collection->addFieldToFilter('state', 'complete');
        }
    }

}

See Adding A Column To Magento Orders Grid - Alternative Way Using Layout Handles

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top