1

I want to display products on homepage according to the value of the position. Suppose i have product category Wood having 4 products then product having position value 1 will be shown first then position value 2 will be shown and the product having position value 4 will be shown in last.

  • grab your product collection for category 123 (wood) and order your collection by position by joining the catalog_category_product table – Julien Lachal Jun 3 '15 at 13:17
1
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->getAttributeToSelect('*');
$collection->setOrder('position', 'ASC');

foreach($collection as $_product)
{
    $_product = Mage::getModel('catalog/product')->load($_product->getId()) ; 
    //enter what you do here.

}

So what you are doing here is 1 get the entire product collection. 2 Selecting all the attributes (this is not very resource efficient you should only select the required attribtues). thirdly you set the collection order by the position attribute and order it ascending.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.