我有这个功能:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.order_id',array('increment_id'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
increment_id已经存在,所以当我手动运行脚本时,我得到2个名为“increment_id”的列,所以我想从第二个$ collection命名increment_id。
我尝试过:$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.order_id',array('increment_id AS increment_id2'));
但这不起作用: - (
答案 0 :(得分:0)
尝试这样的事情(尚未测试)
$collection->getSelect()->join(
array("sfi"=>'sales_flat_invoice'),
'main_table.entity_id = sfi.order_id',
'sfi.increment_id AS increment_id2');
来自http://prattski.com/2010/10/21/magento-collection-join-does-not-allow-table-aliases/