Я изменил app / code / local / Mage / Adminhtml / Block / Sales / Order / Grid.php , чтобы настроить, что находится в сетке Orders .
В _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'
) ко всем необходимым компонентам, и все они прекрасно работают, КРОМЕ этих двух полей Billing или Shipping .
Так что я поставил filter_index на них тоже.
Все идет отлично. Я могу искать другие поля, но как только я ищу в полях Billing или Shipping , я получаю эту ошибку:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'billing_name' in 'where clause'
Я пробовал все виды вещей, но, похоже, ничего не работает. Может кто-нибудь, пожалуйста, помогите! ???