gpt4 book ai didi

Magento - 将邮政编码/邮政编码添加到 Magento 1.6.2 中的订单网格

转载 作者:行者123 更新时间:2023-12-04 05:14:42 24 4
gpt4 key购买 nike

我试图让订单网格显示客户的邮政编码/邮政编码。

我正在尝试将 sales_flat_order_address 别名与集合加入,但没有成功。

protected function _prepareCollection() {
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id',array('postcode'));
//var_dump($collection);
$this->setCollection($collection);
return parent::_prepareCollection();
}

任何人都可以帮我找出解决方案。

最佳答案

在返回 parent::_prepareCollection() 之前;您应该创建一个联接:

$collection->getSelect()->joinLeft(array('billing'=>'sales_flat_order_address'),
'main_table.entity_id = billing.parent_id AND billing.address_type="billing"',array('billing.postcode AS bp'));

如果您想要运输邮政编码,请使用:
$collection->getSelect()->joinLeft(array('shipping'=>'sales_flat_order_address'),
'main_table.entity_id = shipping.parent_id AND shipping.address_type="shipping"',array('shipping.postcode AS sp'));

并在 _prepareColumns 方法中粘贴:
$this->addColumn('bp', array(
'header' => Mage::helper('sales')->__('Billing Postcode'),
'index' => 'bp',
'width' => '60px',
'filter_index' => 'billing.postcode'
));

这在最近的一个项目中对我有用。

关于Magento - 将邮政编码/邮政编码添加到 Magento 1.6.2 中的订单网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14441480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com