нека опитаме този първи код
public function setCollection($collection){
parent::setCollection($collection);
$collection->getSelect()->join(
array('address_shipping' => $collection->getTable("sales/order_address")),
'main_table.entity_id = address_shipping.parent_id AND address_shipping.address_type = "shipping"',
array('address_shipping.postcode as shippingpostcode')
);
$collection->getSelect()->join(
array('address_billing' => $collection->getTable("sales/order_address")),
'main_table.entity_id = address_billing.parent_id AND address_billing.address_type = "billing"',
array('address_billing.postcode as billingpostcode')
);
}
Вторият _prepareColumns()
е тук,
protected function _prepareColumns(){
$this->addColumn('shippingpostcode', array(
'header' => Mage::helper('sales')->__('Shipping Postcode'),
'index' => 'shippingpostcode',
'filter_index' => 'address_shipping.postcode'
));
$this->addColumn('billingpostcode', array(
'header' => Mage::helper('sales')->__('Billing Postcode'),
'index' => 'billingpostcode',
'filter_index' => 'address_billing.postcode'
));
return parent::_prepareColumns();
}
ако искате да научите повече за 'filter_index'
, коментирайте/изключете това, след което опитайте да сортирате в решетката си за колона с пощенски код. Ще видите различен резултат. Ако премахнете filter_index
, грешка при сортиране.