我有2個自定義收集。具有平坦數據的常用集合。 我需要加入他們的客戶選擇。它適用於innerJoin,但對連接字段進行過濾和排序不起作用。我該如何解決這個問題?Magento Grid - 在將平臺加入EAV後排序和過濾工作不正確
_prepareCollection()例如
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email');
$collection
->getSelect()
->joinInner(array('my_table' => $collection->getTable('my/table')), 'e.entity_id = my_table.customer_id', array('custom_field' => my_table.custom_field))
->joinInner(array('my_table1' => $collection->getTable('my/table1')), 'my_table1.other_id = my_table.id', array('custom_field1' => my_table1.custom_field));
$this->setCollection($collection);
return parent::_prepareCollection();
因此,排序和過濾不會爲custom_field工作,custom_field1
添加列呼叫:
$this->addColumn('custom_field',
array(
'header'=>$this->__('Shopping club name'),
'index'=>'custom_field',
'filter_index'=>'my_table.custom_field',
));
同時過濾我得到致命錯誤:
Call to a member function getBackend() on a non-object
排序不起作用,沒有顯示錯誤
'filter_index'可以正常工作,如果你加入扁平表。但這裏平坦的加入了EAV。
出色地工作!排序真棒!謝謝! – freento
可能需要一些更改: 'filter_condition_callback'=>數組($ this,'filter_last_login'), 'order_callback'=> array($ this,'sort_last_login') –
這個問題很老,所以我不打算更新。但是,黃,添加更好。那時我不知道這件事。可以定義集合內的功能,好多了。 – Ian