Magento-将新列添加到销售订单网格不起作用
我正在尝试向Magento的销售订单网格(管理>销售>订单)添加一个新列。我尝试按照此处的说明进行操作: 我已将核心文件复制到本地文件夹,以便覆盖它: From:/public\u html/wholesale/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php 致:/public\u html/wholesale/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php 奇怪的是,无论我对其中一个文件做了什么更改,在管理方面都没有任何更改。我甚至不能让Mage::log()工作 一旦我克服了这个问题,我需要确保我所做的改变是正确的。我只是想知道客户的公司名称。以下是我添加的两个部分:Magento-将新列添加到销售订单网格不起作用,magento,grid,admin,ecommerce-sales,Magento,Grid,Admin,Ecommerce Sales,我正在尝试向Magento的销售订单网格(管理>销售>订单)添加一个新列。我尝试按照此处的说明进行操作: 我已将核心文件复制到本地文件夹,以便覆盖它: From:/public\u html/wholesale/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php 致:/public\u html/wholesale/app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php 奇怪的
protected function _prepareCollection()
{
// This line is from the original
$collection = Mage::getResourceModel($this->_getCollectionClass());
// This is the call where I try to bring in the extra field
// from another sales table
$collection->getSelect()->join(
'sales_flat_order_address',
'sales_flat_order.entity_id = sales_flat_order_address.parent_id',
array('company')
);
// These lines are also default
$this->setCollection($collection);
return parent::_prepareCollection();
}
在_prepareColumns()中:
仅供参考,我正在使用Magento 1.7.0.2,请尝试以下操作:
protected function _prepareCollection()
{
// This line is from the original
$collection = Mage::getResourceModel($this->_getCollectionClass());
// Join billing 'company' field from sales_flat_order_address table
$collection->getSelect()->join(
array('addressTable' => 'sales_flat_order_address'),
'main_table.entity_id = addressTable.parent_id AND addressTable.address_type = "billing"',
array('billing_company'=>'company')
);
// These lines are also default
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function filterBillingCompany($collection, $column) {
$val = (string)trim($column->getFilter()->getValue());
if ($val != "") {
$collection->getSelect()->where("addressTable.company LIKE '%{$val}%'");
}
return $this;
}
在_prepareColumns()中:
protected function _prepareCollection()
{
// This line is from the original
$collection = Mage::getResourceModel($this->_getCollectionClass());
// Join billing 'company' field from sales_flat_order_address table
$collection->getSelect()->join(
array('addressTable' => 'sales_flat_order_address'),
'main_table.entity_id = addressTable.parent_id AND addressTable.address_type = "billing"',
array('billing_company'=>'company')
);
// These lines are also default
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function filterBillingCompany($collection, $column) {
$val = (string)trim($column->getFilter()->getValue());
if ($val != "") {
$collection->getSelect()->where("addressTable.company LIKE '%{$val}%'");
}
return $this;
}
$this->addColumn('company', array(
'header' => Mage::helper('sales')->__('Company'),
'index' => 'billing_company',
'filter_condition_callback' => array($this, 'filterBillingCompany'),
));