Do not want to see disabled products when creating an order from admin end
Question
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
Solution
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!