1

I am using Magento ver. 1.7.0.2 ,In that the product have description attribute and the type is text area. so i can't change 'Used for Sorting in Product Listing' to 'yes'. I want to sort products by description attribute. how can i list the products by using description attribute

I want to add the description attribute in "sort by ->drop down list" and will list the products by description attribute when selecting description from the drop down

0

2 Answers 2

2

Try this :

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect('*');
$_productCollection->addAttributeToSort('description', 'ASC');
echo "<pre>";print_r($_productCollection->getData());
5
  • plz help ,where i put this code? in toolbar.phtml? there have the code <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>> <?php echo $this->__($_order) ?> </option>
    – Asha
    May 25, 2015 at 9:33
  • try to add this line : $_productCollection->addAttributeToSort('description', 'ASC'); after $_productCollection=$this->getLoadedProductCollection(); in the list.phtml. Ofcourse my advice would be to copy the list.phtml in your local folder. May 25, 2015 at 9:39
  • sorry, i want to add the description attribute in "sort by ->drop down list" and listing products by description attribute when selecting description from the drop down
    – Asha
    May 25, 2015 at 9:48
  • 1
    Please decide what you want exactly and then post. May 25, 2015 at 9:54
  • the above one is my problem
    – Asha
    May 25, 2015 at 9:55
1

Check the following article i believe you will find helpful.

how to sort products in the category products listing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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