Product Collection in Magento

Hello All,

I am writing here the script to get product collection of the store.


	$collection = Mage::getResourceModel('catalog/product_collection');  		   

	$collection->addAttributeToFilter('status',1); //only enabled product

	$collection->addAttributeToFilter('visibility',array("neq"=>1)); //except not visible individually

	$collection->addAttributeToSelect(array('name','url','small_image')); //add product attribute to be fetched

        //$collection->getSelect()->order('rand()');	 //uncomment to get products in random order   




     	    foreach ($collection as $_product): 

			echo $_product->getName();	//get product name			




    	     echo 'No products exists';




Hope this is helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top