I want to display products between range of 5000 to 10000 on top in my category page, how can i do this in magento?

I tried to merge collection using

$_productCollection1 = Mage::getModel('catalog/product')
                              ->addAttributeToFilter('showontop', 1)

$_productCollection2 = array();
$_productCollection2 = Mage::getModel('catalog/product')
                              ->addAttributeToFilter('showontop', 0)
print_r($_productCollection2->getAllIds()); die();
$merged_ids = array_merge($_productCollection1->getAllIds(), $_productCollection2->getAllIds());

$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addFieldToFilter('entity_id', array('in' => $merged_ids))

but no result

  • what u mean by range of 5000 to 10000?
    – Amit Bera
    Jan 26, 2017 at 7:54
  • products price between these range and all products between this range have attribute showontop as yes.
    – Sunil
    Jan 26, 2017 at 8:39

3 Answers 3


u can achieved result by single collection instead of three collection

try this

$_productCollection1 = Mage::getModel('catalog/product')
                        array('showontop', 'showontop'),
                            array('eq'=> 1 ), 
                            array('eq'=> 0 )
  • u can alos set limit $_productCollection1->setPage(5000,10000) Feb 3, 2017 at 12:45

you can price limit by following code

$products = Mage::getModel('catalog/product')->getCollection()
         ->addFieldToFilter('entity_id', array('in' => $merged_ids));


// Apply price limit
$products->getSelect()->where('price_index.final_price <= ?', 10000)
->where('price_index.final_price >= ?', 5000);
      echo '<pre>';   print_r($products->getData());

Below code work for me for getting products whose price between 5000 to 10000

Hope it will help you

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

Your Answer

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

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