How to show Products collection in Magento?

Sharing is caring!

You can use below code to get all Products collection in Magento on any of Magento page:

$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToFilter('status', 1); //enabled or not
$_productCollection->addAttributeToFilter('visibility', 4); //catalog, search enabled or not
foreach ($_productCollection as $_product)
{
$model = Mage::getModel('catalog/product');
$product_id = $_product->getId();
$_product = $model->load($product_id);
$_image=Mage::getModel('catalog/product')->load($product_id);

<div class="feature-product-price"><?php echo $_product->getPrice(); ?></div> <div class="feature-product-name"><?php echo $_product->getName(); ?></div> <div class="feature-product-image"><a href="<?php echo $_product->getProductUrl() ?>"><img src="<?php echo Mage::helper('catalog/image')->init($_image, 'image')->resize(200,200); ?>"></a></div> </div> <?php } [sam_zone id="1" codes="true"]

If you want Product Collection with specific ids then use below code

getCollection();
$_productCollection->addAttributeToFilter('status', 1); //enabled
$_productCollection->addAttributeToFilter('visibility', 4); //catalog, search
$_productCollection->addAttributeToFilter('entity_id', array('in' => $productIds));


foreach ($_productCollection as $_product)
{

$model = Mage::getModel('catalog/product');
$product_id = $_product->getId();
$_product = $model->load($product_id);
$_image=Mage::getModel('catalog/product')->load($product_id);
?>
;
resize(200,200); >"

Leave a Reply

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

Got Project on mind? Let's ConnectContact Us

Secured By miniOrange