Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

setOrder function not work in v.1.3.2.1? 
 
CharlieXun
Jr. Member
 
Total Posts:  30
Joined:  2009-04-12
 

Hi,

I use the following function to sort my products on Observer

$observer->getEvent()->getCollection()->setOrder("name""ASC");

It worked perfectly in v.1.3.1.1 but when I upgraded to v.1.3.2.1, it did’t work any more.

Can anyone tell me the reason or some other alternative solutions?

 
Magento Community Magento Community
Magento Community
Magento Community
 
magedev
Sr. Member
 
Avatar
Total Posts:  117
Joined:  2009-06-01
 

Try to check what data is hold in your event object:

var_dump($observer->getEvent()->getData());

Probably you want to get collection of objects stored in your event data. Just a guess…

 
Magento Community Magento Community
Magento Community
Magento Community
 
CharlieXun
Jr. Member
 
Total Posts:  30
Joined:  2009-04-12
 

The object is Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection, and its the parent class Mage_Eav_Model_Entity_Collection_Abstract it has setOrder funciton. So I don’t know what happened?? Is it the latest the documentation in Magento site?

 
Magento Community Magento Community
Magento Community
Magento Community
 
magedev
Sr. Member
 
Avatar
Total Posts:  117
Joined:  2009-06-01
 

Chances are the $observer->getEvent() is an instance of VarienEvent class, probably you’ve got to get data stored in event in a way similar to:

$observer->getEvent()->getData('products')->getCollection()->setOrder()
. I don’t know what data is stored in your event so I propse to check it using code I posted above. Hope it helps.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top