Question

I'm using Magento CE 1.7. I have several stores in admin panel. I want to get both the enabled and disabled products collection in admin panel when create new order. When click the add Products button the grid should all the products(even if they are expired, disabled, out of stock or whatever the status) under the current store. How can I get this collection?

Please any help will be appreciated.

EDIT: Override the block class Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid

Edited the following function.

protected function _prepareCollection()
    {
   $currentStore = Mage::getSingleton('adminhtml/session_quote')->getStore();
    $collection = Mage::getModel('catalog/product')->getCollection();
$collection

            ->setStore($currentStore)
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('sku')
            ->addAttributeToSelect('price')
            ->addAttributeToSelect('status')
            ->addAttributeToFilter('type_id', array_keys(
                Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
            ))
            ->addStoreFilter();
$this->setCollection($collection);
        Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
}
Was it helpful?

Solution

In the method Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid::_prepareCollection there is this line that filters only in stock products: Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
But changing this might lead to other issues since there are verifications when placing the order for example in Mage_Adminhtml_Block_Sales_Order_Create_Items_Grid::getItems.
But it's a good place to start.

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