Question

I'm getting all products with this code:

$collection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addStoreFilter()
->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection->getSelect()->order('rand()');
$collection->getSelect()->limit(12);

Can I add price range? Like "price > 1000 && price < 5000" ?

Was it helpful?

Solution

Try this

$collection->addAttributeToFilter('price', array('gt'=>1000));
$collection->addAttributeToFilter('price', array('lt'=>5000));

OTHER TIPS

also you can check this

$collection->addAttributeToFilter('price', array('from'=>'1000','to'=>'5000'));
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top