【发布时间】:2018-03-13 06:56:50
【问题描述】:
我想覆盖 Magento 管理员中的销售订单网格。我为此创建了自定义模块,但似乎我的覆盖不起作用。没有错误。
请在上面找到我的代码:
app/etc/modules/
<config>
<modules>
<Bikebear_SalesGrid>
<active>true</active>
<codePool>local</codePool>
</Bikebear_SalesGrid>
</modules>
app/code/local/Bikebear/SalesGrid/等
<config>
<modules>
<Bikebear_SalesGrid>
<version>1.0.0</version>
</Bikebear_SalesGrid>
</modules>
<global>
<blocks>
<ordergrid>
<class>Bikebear_SalesGrid_Block</class>
</ordergrid>
<adminhtml>
<rewrite>
<sales_order_grid>Bikebear_SalesGrid_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
app/code/local/Bikebear/SalesGrid/Block/Adminhtml/Sales/Order
class Bikebear_SalesGrid_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
protected function _prepareCollection(){
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
return $this;
}
protected function _prepareColumns()
{
$this->addColumn('real_order_id', array(
'header'=> Mage::helper('sales')->__('Order #'),
'width' => '80px',
'type' => 'text',
'index' => 'increment_id',
));
$this->addColumn('postcode', array(
'header' => Mage::helper('sales')->__('Postcode 1'),
'index' => 'postcode',
));
if (!Mage::app()->isSingleStoreMode()) {
$this->addColumn('store_id', array(
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
'index' => 'store_id',
'type' => 'store',
'store_view'=> true,
'display_deleted' => true,
));
}
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'width' => '100px',
));
/*$this->addColumn('billing_name', array(
'header' => Mage::helper('sales')->__('Bill to Name'),
'index' => 'billing_name',
));*/
$this->addColumn('shipping_name', array(
'header' => Mage::helper('sales')->__('Ship to Name'),
'index' => 'shipping_name',
));
/*$this->addColumn('base_grand_total', array(
'header' => Mage::helper('sales')->__('G.T. (Base)'),
'index' => 'base_grand_total',
'type' => 'currency',
'currency' => 'base_currency_code',
));*/
$this->addColumn('grand_total', array(
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
'index' => 'grand_total',
'type' => 'currency',
'currency' => 'order_currency_code',
));
$this->addColumn('status', array(
'header' => Mage::helper('sales')->__('Status'),
'index' => 'status',
'type' => 'options',
'width' => '70px',
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
));
return parent::_prepareColumns();
}}
我做错了什么,为什么没有结果?提前致谢。
【问题讨论】:
-
首先,覆盖这个网格的目的是什么?你想用它做什么?您是否只想隐藏示例中的几列?在 Magento 中,覆盖不是一个好的做法,在大多数情况下,您可以使用观察者。请建议您想做什么,我可以尽力帮助您。谢谢。
-
实际上我想隐藏“base_grand_total”和“billing_name”,我想为“送货地址”和“交货日期”添加新列。请帮助我,请让我知道如何实现这一目标。谢谢
标签: magento magento-1.7