該修補程序需要一些修改才能工作。但是,代碼最好放在不同類的模型重寫中。
爲我工作的解決方案是重寫Mage_Eav_Model_Entity_Attribute_Source_Table::addValueSortToCollection
和下面的代碼添加到函數的末尾:
$attribute = $this->getAttribute();
$order = $attribute->getAttributeCode();
$dir = strtoupper($dir);
$collection->getSelect()->reset(Zend_Db_Select::ORDER);
$collection->getSelect()
->joinLeft('eav_attribute_option AS eao', "eao.option_id=IF({$order}_t2.value_id > 0, {$order}_t2.value, {$order}_t1.value)", array("sort_order" => 'eao.option_id'))
->order(new Zend_Db_Expr('eao.sort_order '.$dir));
一個人必須知道,這將替換值排序爲option_id排序爲每個目錄收集和每個屬性,其源模型類是eav/entity_attribute_source_table
謝謝,這工作完美。在表前綴的情況下,只有一個問題需要使用Mage :: getSingleton('core/resource') - > getTableName('eav_attribute_option')。 – 2013-02-18 13:14:56
你是對的,謝謝你的留言 – 2013-02-18 13:27:28