7

When you click on a customer in "manage customers" and then "create order", my client does not want to see the disabled products come up in the list for products to add to order. Any idea how I would go about changing this? Or at least some file location hints, lol.

I'm editing the following per below advice.

 protected function _prepareCollection()
    {
        $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
        /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
        $collection = Mage::getModel('catalog/product')->getCollection();
        $collection
            ->setStore($this->getStore())
            ->addAttributeToSelect($attributes)
            ->addAttributeToSelect('sku')
            ->addStoreFilter()
            ->addAttributeToFilter('type_id', array_keys(
                Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
            ))
            ->addAttributeToSelect('gift_message_available');
            ->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
        Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);

        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

As you can see I added ->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED); but am getting following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/ab71714/public_html/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php on line 109

1
  • 2
    Don't edit the core. If you must, copy the file and the full path into app/code/local.
    – philwinkle
    Commented Apr 17, 2013 at 22:23

1 Answer 1

4

The class you are looking for is: Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid

Override the _prepareCollection() and add a filter to the $collection like so:

$collection->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)

This should filter all disabled products and only show enabled ones. Tested with CE 1.7

Hope this helps!

2
  • I get an error. See above. Thank you so much for your help! Commented Apr 11, 2013 at 21:51
  • Oh wait, im such a dummy! it has to go after Mage::getSingleton('catalog/product_status'). Works now! THank you!!! Commented Apr 11, 2013 at 21:55

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.