嘗試過濾管理網格以查看特定產品上的銷售歷史記錄,但在嘗試按帳單過濾時收到以下錯誤名稱:Magento:SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'billing_name'
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
這裏是我使用的是什麼:
protected function _prepareCollection() {
$productId = $this->getProduct()->getId();
$ordersId = $this->getOrderIds($productId);
$collection = mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('main_table.entity_id', array('in' => $ordersId))
->join('sales/order_address', '`sales/order_address`.entity_id=billing_address_id', array('billing_name' => "concat(firstname, ' ', lastname)"));
$this->setCollection($collection);
return parent::_prepareCollection();
}
然後添加格列記帳名稱:
protected function _prepareColumns() {
$this->addColumn('billing_name', array(
'header' => Mage::helper('AdvancedStock')->__('Bill to Name'),
'index' => 'billing_name',
'sortable' => true
));
return parent::_prepareColumns();
}
該列將正確返回包含產品的訂單中的所有開票名稱,我只是無法按名稱過濾該列。有任何想法嗎?
您已將計費名稱添加到模型,但不是數據庫?當您查看'sales_flat_order'(或者它是否是'sales_flat_order_address')表時,它是否存在? – CD001
@ CD001我相信它在'sales_flat_order_address'中,雖然我沒有訪問phpMyAdmin來檢查表格 – AJ47