0

I am working on Magento, I want to create new custom field with filter in Sales > Order > Create new order > Add product grid.

Let me know please how can i do it.

enter image description here

Thanks.

0

You will need to override a class Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid.

Go to your config.xml and add this

<global>
    <blocks>
        ......................          
        <adminhtml>
            <rewrite>
                <sales_order_create_search_grid>Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid</sales_order_create_search_grid>
            </rewrite>
        </adminhtml>
    </blocks>
.............
</global>

Now create a file Namespace/ModuleName/Block/Adminhtml/Sales/Order/Create/Search/Grid.php and have this code:

<?php
class Namespace_ModuleName_Block_Adminhtml_Sales_Order_Create_Search_Grid extends 
    Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid
{

/**
 * Prepare collection to be displayed in the grid
 *
 * @return Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid
 */
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')
        //our new field.
        ->addAttributeToSelect('type_id');

    Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);

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


protected function _prepareColumns()
    {
        parent::_prepareColumns();
        $this->addColumn('type',
          array(
            'header'=> Mage::helper('sales')->__('Type'),
            'width' => '60px',
            'index' => 'type_id',
            'type'  => 'options',
            'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
      ));
        return parent::_prepareColumns();
    }

}

This will add a product type in grid.

Hope this helps. Good luck.

0

You have to override a class Mage_Adminhtml_Block_Sales_Order_Create_Search_Grid to local code pool from core code pool

And in that add column whatever you want

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy