6

In sales/orders is it possible to hide completed orders ? using something like filters.

or can I filter the status column with more than one status ?

4
  • which magento version?
    – Amit Bera
    Commented Apr 27, 2016 at 18:44
  • Are u want to show order grid with out complete order?
    – Amit Bera
    Commented Apr 27, 2016 at 18:50
  • magento 1.9.2.4
    – mubdea
    Commented Apr 27, 2016 at 19:04
  • yes I want to show order grid with out complete order. but only when I want to not permanently
    – mubdea
    Commented Apr 27, 2016 at 19:05

2 Answers 2

5

The observer way:

<events>
    <sales_order_grid_collection_load_before>
        <observers>
            <vendor_module_salesgrid>
                <model>module/observer</model>
                <method>filterGrid</method>
            </vendor_module_salesgrid>
        </observers>
    </sales_order_grid_collection_load_before>
</events>

Then in your module/Model/Observer.php

<?php

class Vendor_Module_Model_Observer 
{
    public function filterGrid(Varien_Event_Observer $observer)
    {
        $collection = $observer->getOrderGridCollection();
        $collection->addFieldToFilter('status',array('neq', 'complete'));
    }
}
1

Magento sales order grid collection generate from Mage_Adminhtml_Block_Sales_Order_Grid at class _prepareCollection function.

you need to modify the collection from here.

So you need to override that class

<?php
class [ModuleNameSpace_ModuleName]_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{ 
  protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
            // filter ty status 
        $collection ->addFieldToFilter('status',array('neq', 'complete'));
        $this->setCollection($collection);
        return parent::_prepareCollection();
    } 
}
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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