Magento:对Varien数据收集的项目进行排序

Magento:对Varien数据收集的项目进行排序,magento,Magento,我想使用自定义属性对Magento中的Varien_对象进行排序。 我得到了这样的东西: $thing_1 = new Varien_Object(); $thing_1->setName('Richard'); $thing_1->setOrder(2); $thing_2 = new Varien_Object(); $thing_2->setName('Jane'); $thing_2->setOrder(1); $collection_of_things =

我想使用自定义属性对Magento中的Varien_对象进行排序。
我得到了这样的东西:

$thing_1 = new Varien_Object();
$thing_1->setName('Richard');
$thing_1->setOrder(2);

$thing_2 = new Varien_Object();
$thing_2->setName('Jane');
$thing_2->setOrder(1);

$collection_of_things = new Varien_Data_Collection();
$collection_of_things
    ->addItem($thing_1)
    ->addItem($thing_2);
我想按ASC排序,以便
Jane
可以在
Richard


谢谢。

Varien_数据_集合具有排序方法,但此方法在执行时会呈现给SQL查询

public function setOrder($field, $direction = self::SORT_ORDER_DESC)
如果手动添加项,它将按照添加顺序添加索引,因此您需要先对对象进行排序,然后将其添加到数据集合中


看这个问题

好的,谢谢你的回答。我想避免这样做,但似乎我别无选择。