Wednesday, May 11, 2011

How to show all products image in single page?

Put this code under CMS Page -> Layout Update XML
 <reference name="content">
          <block type="catalog/product" name="imagegallery" template="catalog/product/imagegallery.phtml"/>
  </reference>

app/design/frontend/default/<YOUR THEME>/template/catalog/product/imagegallery.phtml
<?php
    $_productCollection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('visibility', 4)
    ->addAttributeToFilter('status',1)
    //->setPage(1,3)
    ->addAttributeToSort('entity_id', 'DESC');
    $prod_list    =    new Mage_Catalog_Block_Product_List();
    $count        =        4;
?>
<table border="0">
<tbody>
<?php
    foreach($_productCollection as $_product):
    $_product->load($_product->getId());
  if($count % 4 == 0){ echo '<tr style="margin-bottom:20px;">'; }

// Product Image
    echo '<td align="center"><a class="product-image" href='.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_product->getUrlPath().'><img src='.$_product->getImageUrl().' width="80" height="77"  /></a>';

//Product Name
    echo '<h4 class="product-name">'.$_product->getName().'</h4></td>';
    $count++;
    if($count % 4 == 0){ echo "</tr>"; }
    endforeach;
?>
</tbody>
</table>

No comments:

Post a Comment