Search code examples
phpmagentomagento-1.7magento-1.9magento-1.8

Magento. Sort products collection by position


I have products collection.

$_products = Mage::getModel('catalog/product')->getCollection();

In admin panel in Catalog->Manage Categories->Category products i have position for each product. How i can sort $_products by position ?


Solution

  • I have created separated extension which create new products attribute with name 'position'. In this extension i have create observer which listening category save event. So when admin save category in my observer i get each position and set my attribute 'position' for each product. And at at last i can sort products collection by 'position'(product) attribute.