Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:05:33+00:00 2026-05-31T13:05:33+00:00

I am using the following piece of code to allow users to set featured

  • 0

I am using the following piece of code to allow users to set featured products that will display on the homepage but I need to extend this so that they can also dictate the sort order of the items. By default it displays the producst in the order they were added to Magento.

To do this I have created a attribute called “sort_order” that allows the users to add a numerical value that will dictate the sort order when displayed on the homepage. For example if I have 4 products then the sort order could be displayed as followed

product1 – sort order 3
product 2 – sort order 1
product 3 – sort order 2
product 4 – sort order 4

I have been trying all morning get this working. I presume I need to create an array of some sort that allows me to then order the products as dicated by the attribute “sort_order” but i’m not getting anywhere

If anyone can offer some advice I would be very grateful

  <div id="home-featured">
  <h2><?php echo $this->__('Featured') ?></h2>
  <?php
        // some helpers
        $_helper = $this->helper('catalog/output');
        $storeId = Mage::app()->getStore()->getId();
        $catalog =  $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);

        // get all products that are marked as featured
        $collection = Mage::getModel('catalog/product')->getCollection();
        $collection->addAttributeToSelect('featured_product');
        $collection->addFieldToFilter(array(
            array('attribute' => 'featured_product', 'eq' => true),
        ));

        // if no products are currently featured, display some text
        if (!$collection->count()) :
    ?>
  <p class="note-msg"><?php echo $this->__('There are no featured products at the moment.') ?></p>
  <?php else : ?>
  <div class="category-products">
    <?php
        $_collectionSize = $collection->count();
        $_columnCount = 4;
        $i = 0;

        foreach ($collection as $_product) :
        $_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
    ?>
    <article>
      <div class="product-image"><a href="<?php echo Mage::helper('fullurl')->getFullProductUrl($_product); ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" ><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize(170); ?>" width="170" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a></div>
      <div class="featured-info">
        <h3><a href="<?php echo Mage::helper('fullurl')->getFullProductUrl($_product); ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h3>
        <p><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description ') ?></p>
        <span class="link-dreambuilder"><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" ><?php echo $this->__('+ Add to Dream Builder') ?></a></span> </div>
    </article>
    <?php endforeach ?>
  </div>
  <?php endif ?>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:05:34+00:00Added an answer on May 31, 2026 at 1:05 pm

    anyway, here is the attribute sort function..

    addAttributeToSort($attribute, $dir='asc');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following piece of code to pull a stock price from yahoo
I'm using the following piece of code to login a user via Ajax. //Capture
I've recently been using the following piece of code to limit my 2nd Date
I'm using the following piece of Objective-C code to format a NSNumber, and it
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
I'm using the following piece of code and under some mysterious circumstances the result
I'm using the following piece of code: $.log('Ending time: ' + ending_time); $.log('Now: '
I am using the following piece of code to populate my ListView - setListAdapter(new
I am using the following piece of code in my app: string_array = getResources().getStringArray(R.array.array_of_strings);
I am using the following piece of jQuery code: $('div#addMenu1').click(function(){ if (!menuSet1){ menuSet1 =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.