<?php
$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToFilter('feature','1'); //custom attribute is yes/no(1,0)
$_productCollection->addAttributeToFilter('status', 1); //enabled
$_productCollection->addAttributeToFilter('visibility', 4); //catalog, search
?>
<?php
foreach ($_productCollection as $_product)
{
$model = Mage::getModel('catalog/product');
$product_id = $_product->getId();
$_product = $model->load($product_id);
//echo $_product->getPrice()."<br>";
//echo $_product->getName()."<br>";
$_image=Mage::getModel('catalog/product')->load($product_id);
//echo Mage::helper('catalog/image')->init($_image, 'image')."<br>";
?>
<div class="feature-product">
<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
}
?>
This blog is all about magento , php javescript ,mysql codes. In this i am trying to post the posts which i really feel to have these codes always with me and i am trying to publish most challenging codes which we need to use in daily development. I personally sometime needs to spent most of times to get the idea about these codes on net,thats why i thought to put all these codes on one place and i am trying to keep this work going on and in simple way which can help the communty
Monday, 10 November 2014
Magento Products collection in any page
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment