我已經在互聯網上搜索了一個答案,其中包括許多SO問題,但沒有一個問題似乎爲我提供了我所需要的。在Magento中獲取客戶訂單中的訂單和發票網格
我有一個客戶自定義屬性()。我需要能夠在管理區域中的訂單和發票網格中顯示此項。
我已經通過複製Mage_Adminhtml_Block_Orders_Grid
到當地的游泳池,使用下面
$collection->getSelect()
->join(
'sales_flat_order_address',
'main_table.entity_id = sales_flat_order_address.parent_id',
array('email')
);
此代碼,顯然得到了客戶的電子郵件,只適用於該訂單網格。
任何人都可以幫我在這些表中獲得屬性?
使用CE 1.9。
UPDATE
我用下面的代碼加入_prepareCollection()
列:
$gen_number_attr = Mage::getSingleton('customer/customer')->getResource()->getAttribute('gen_number');
$collection->getSelect()->joinLeft(
array(
'table_customer_number' => $gen_number_attr->getBackend()->getTable()),
'main_table.customer_id = table_customer_number.entity_id AND table_customer_number.attribute_id = '.$gen_number_attr->getId(). ' AND table_customer_number.entity_type_id = '.Mage::getSingleton('customer/customer')->getResource()->getTypeId(),
array(
'customer_number' =>'table_customer_number.value'
)
);
現在的問題是,當我試圖篩選我得到以下錯誤:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer_number' in 'where clause', query was: SELECT COUNT(*) FROM `sales_flat_order_grid` AS `main_table`
INNER JOIN `sales_flat_order_address` ON main_table.entity_id = sales_flat_order_address.parent_id WHERE (`customer_number` LIKE '%123%')
任何幫助,將不勝感激!
任何幫助都將不勝感激。必須有人有一個想法 – Wildcard27
轉介此http://magento.stackexchange.com/a/99000/45103 –