我已更改app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php以定製訂單網格上的內容。Magento - SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'billing_name'
在_getCollectionClass()
我有這樣的:
protected function _getCollectionClass()
{
//return 'sales/order_grid_collection';
return 'sales/order_collection';
}
和_prepareCollection()
我有這樣的:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft(array('s1' => 'sales_flat_order_address'),'main_table.shipping_address_id = s1.entity_id',array('region','firstname','lastname'));
$collection->getSelect()->joinLeft(array('s2'=>'sales_flat_order_address'),'main_table.billing_address_id = s2.entity_id',array('firstname','lastname'));
$collection->getSelect()->columns(new Zend_Db_Expr("CONCAT(s2.firstname, ' ',s2.lastname) AS billing_name"));
$collection->getSelect()->columns(new Zend_Db_Expr("CONCAT(s1.firstname, ' ',s1.lastname) AS shipping_name"));
$collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email','sfo.weight','sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status','sfo.base_grand_total','sfo.grand_total')); // New
$collection->getSelect()->joinLeft(array('sfoa'=>'sales_flat_order_address'),'main_table.entity_id = sfoa.parent_id AND sfoa.address_type="shipping"',array('sfoa.street','sfoa.city','sfoa.region','sfoa.postcode','sfoa.telephone')); // New
$this->setCollection($collection);
return parent::_prepareCollection();
}
現在我已經改變了_prepareColumns()
加我必要的字段和所有的偉大工程!除了一件事......
當我通過結算或搜索訂單航運,我得到一個錯誤。我已經添加filter_index的('filter_index' => 'theindex'
)到所有必要的組件,它們都除兩個領域結算或航運工作的偉大。
所以我把filter_index也是這樣。
一切都很好。我可以搜索其他的領域,但只要我搜索了結算或航運領域,我得到這個錯誤:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
我已經嘗試了各種各樣的事情,但似乎沒有任何工作。有人可以幫助!???