1

I want to load data from a table using collection and I need the result to be in the ascending order of the 'sort_order' column which is an integer value.admin form

The above pic shows the columns in admin form.

Database Table

The above pic is of the database table.

This is the code which I used to retrieve the collection.

 $collection = Mage::getModel('hm_faq/object')->getCollection()->addFieldToFilter('category_id',$category->getId()); $collection->setPageSize(5); $collection->setCurPage(2); $size = $collection->getSize(); $cnt = count($collection); foreach ($collection as $button) { $i = $i+1; ?> <a id="<?php echo $button->getUrlId(); ?>" href="<?php echo $button->getUrlLink(); ?>" > <div class="faq-white-button"> <div class="faq-inner"> <h3 class="faq-button-label"><?php echo $button->getUrlLabel(); ?></h3><span class="faq-icon">></span> </div> </div> </a> <?php echo '<br>';} ?> 

How can i arrange the result in the ascending order of the sort_order?

1 Answer 1

4

Try with this:

$collection->setOrder('sort_order', 'ASC'); 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.