Home

Tuesday, January 8, 2013

Category id wise Display a products in Magento

Category id wise Display a products in Magento

require_once ("D:\wamp\www\examples\magento\app\Mage.php");
umask(0);
Mage::app("default");

/////////////// CATEGORY ID WISE DISPALY ALL PRODUCTS ////////////////   
    $cat_id = 5;
    $collection = Mage::getModel('catalog/category')->load($cat_id)
                         ->getProductCollection()
                         ->addAttributeToSelect('*')
                         ->addAttributeToFilter('status', 1)
                         ->addAttributeToFilter('visibility', 4)
                         ->setOrder('name', 'ASC') ;
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
<table width="100%" border="1">
            <tr>
                <th>Product ID</th>
                <th>Product Name</th>
                <th>SKU</th>
                <th>Price</th>              
                <th>Thumbnail</th>
                <th>Small</th>
                <th>Big</th>
            </tr>
<?php
    foreach ($collection as $product)
    {
        ?>
        <tr>
            <td><?php echo $product->getId();?></td>
            <td><?php echo $product->getName();?></td>
            <td><?php echo $product->getSku();?></td>
            <td><?php echo $product->getPrice();?></td>           
            <td>
                <a href="<?php echo $product->getProductUrl();?>" target="_blank"><img src="<?php echo $product->getThumbnailUrl();?>" /></a>
            </td>
            <td><img src="<?php echo $product->getSmallImageUrl();?>" /></td>
            <td><img src="<?php echo $product->getImageUrl();?>" /></td>
        </tr>
        <?php       
    }
    ?></table>

No comments:

Post a Comment

rathoddhirendra.blogspot.com-Google pagerank and Worth