1
基本上,我希望鏈接sales/order和sales/order_invoice表,以便在通過發票循環時從sales/order獲取order_source feild;magento加入訂單和發票
這是我attmpt:
$collection = Mage::getModel('sales/order_invoice')->getCollection();
$collection = $collection->addAttributeToFilter('order_id', array('from' =>$from));
$collection->joinAttribute('order_source', 'order/order_source', 'order_id', null, 'left');
foreach($collection as $invoice){
$orderSource = $invoice->getOrderSource();
//do other stuff
}
我是新來的Magento
order_source是我添加的客戶屬性 – rosh3000
'joinAttribute'對我來說看起來不錯。你能解釋什麼是錯的嗎? – clockworkgeek
@clockworkgeek我無法訪問該變量,即它始終是'null',當我嘗試排序時發現問題,因爲它給了我一個錯誤消息:'致命錯誤:... Main_table.order_source未找到... (你說的沒錯,joinAttribute') – rosh3000