我能夠通過添加以下行到config.xml改寫
<global>
<!-- -->
<models>
<sales_mysql4>
<rewrite>
<order_collection>Company_ModelName_Model_Mysql4_Order_Collection</order_collection>
</rewrite>
</sales_mysql4>
</models>
<!-- -->
</global>
然後我添加類Collection.php在擴展Mage_Sales_Model_Mysql4_Order_Collection
即使這將覆蓋該命令集合類它給出了一個錯誤的型號/ Mysql4 /訂單文件夾(調用一個成員福當運行以下代碼時,在nction joinAttribute()非空對象): Mage :: getResourceModel('sales/order_collection') - > addAttributeToSelect('*') - > joinAttribute('billing_firstname','order_address/firstname',' billing_address_id',null,'left');
如果重新排列上面的線劃分成以下3行它不給錯誤:
$集合=法師:: getResourceModel( '銷售/ order_collection'); $ collection-> addAttributeToSelect('*');
$ collection-> joinAttribute('billing_firstname','order_address/firstname','billing_address_id',null,'left');
我認爲這是一個在Magento中的錯誤。你怎麼看?
感謝Margots
當我重寫方法addAttributeToSelect()我叫父:: addAttributeToSelect(),但再也沒有回來呢?那是不是一個錯誤......。所以,通過在parent :: addAttributeToSelect()前添加'return' – latvian 2010-03-20 00:39:27