1

我想在搜索网格(Sales_Order_Create_Search_Grid)的产品选择阶段显示订单创建(后端)的库存水平: 在此处输入图像描述

我该怎么做呢?

4

1 回答 1

1

有3个步骤。

第一:找到这个文件:

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php

并将其复制到:

app/code/local/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid.php

这将有助于确保您不会覆盖核心文件,而是创建不受升级影响的本地版本。

第二:在新文件中,_prepareCollection() 函数的代码如下:

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection
        ->setStore($this->getStore())
        ->addAttributeToSelect($attributes)
        ->addStoreFilter()
        ->addAttributeToFilter('type_id', array_keys(
            Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
        ))
        ->addAttributeToSelect('gift_message_available');

将此代码添加到该块:

        ->joinField('qty2',
            'cataloginventory/stock_item',
            'qty','product_id=entity_id','{{table}}.stock_id=1','left')

所以完成的版本看起来像:

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection
        ->setStore($this->getStore())
        ->addAttributeToSelect($attributes)
        ->joinField('qty2',
            'cataloginventory/stock_item',
            'qty','product_id=entity_id','{{table}}.stock_id=1','left')
        ->addStoreFilter()
        ->addAttributeToFilter('type_id', array_keys(
            Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()
        ))
        ->addAttributeToSelect('gift_message_available');

第三:仍然在新文件中,找到_prepareColumns()函数并添加以下代码:

    $this->addColumn('qty2', array(
        'header'    => Mage::helper('sales')->__('Stock Level'),
        'width'     => '20',
        'type'      => 'number',
        'index'     => 'qty2'
    ));

将上述代码块添加到 _prepareColumns() 函数的位置将确定“库存水平”列在网格上的显示顺序。

而已。

于 2013-11-04T00:57:17.270 回答