我有这个功能:
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'));
但这不起作用:-(