Magento Questions Answered By Magento Experts

 

Welcome Guest. Sign in or Signup

4 Answers

2 ranges of product on the homepage

Asked by: 1403 views , ,
Questions

Hello,

We use a theme for magento and it’s only display one range on the homepage. We would like to know how to display 2 or 3 range on this homepage, here is my website :

www.harneyshop.com

How to display 2 or 3 range of products under the “Produit à la une” title. Here is the part of the code which generate that in the new.phtml :

<table cellspacing=”0″ class=”generic-product-grid” id=”new-products-list-table”>
        <tr>
        <?php $i=0; foreach ($_products->getItems() as $_product): ?>
            <?php if ($i>=5): continue; endif; ?>
       
            <td>
                <p class=”product-image”>
                    <a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(120) ?>” width=”120″ height=”120″ alt=”<?php echo $this->htmlEscape($_product->getName()) ?>” /></a>
                </p>
                <p class=”product-name-p”><a class=”product-name” href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>)”><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
                <?php echo $this->getReviewsSummaryHtml($_product, ‘short’) ?>
                <?php echo $this->getPriceHtml($_product, true, ‘-new’) ?>
                <?php if($_product->isSaleable()): ?>
                    <a href=”<?php echo $this->getAddToCartUrl($_product) ?>” class=”shop-now” style=”margin:0 auto;”>Buy Now</a>
                <?php else: ?>
                <div class=”out-of-stock”><?php echo $this->__(‘Out of stock’) ?></div>
                <?php endif; ?>
                <div class=”clear”></div>
                <?php /*?><ul class=”add-to”>
                    <?php if ($this->helper(‘wishlist’)->isAllow()) : ?>
                        <li><a href=”<?php echo $this->getAddToWishlistUrl($_product) ?>” class=”link-cart”><?php echo $this->__(‘Add to Wishlist’) ?></a></li>
                    <?php endif; ?>
                    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                        <li><a href=”<?php echo $_compareUrl ?>”><?php echo $this->__(‘Add to Compare’) ?></a></li>
                    <?php endif; ?>
                </ul><?php */?>
                </td>
        <?php $i++; endforeach; ?>
        <?php for($i;$i%5!=0;$i++): ?>
                <td>&nbsp;</td>
            <?php endfor ?>
            </tr>
    </table>

Thank you.

Greetings,
LC

4 Answers



  1. justin on Jun 04, 2010 Reply

    Are you wanting to do a similar thing to what is on http://www.happycow.com.au? With two ‘categories’ of products being shown simultaneously?

    To do this we call the blocks to the page (cms > pages) using:

    {{block type=”catalog/product_list” category_id=”XX” template=”catalog/product/list.phtml”}}

    You can have as many of these on one page as you want, just change the category id for the appropriate one you want too use.

    If you want to modify the category product design, duplicate ‘list.phtml’ as ‘list2.phtml’, make your changes then remember to update the last part of the code (where the template is being called from so it becomes “catalog/product/list2.phtml”, this way you wont stuff up the design of your existing category pages.

    +1 Votes Thumb up 1 Votes Thumb down 0 Votes



  2. Magento on Jun 04, 2010 Reply

    One thing to keep in mind is that magento is built to render 5 new products by default – and not more.

    If you want to render more than 5 new products, one way to easily do that is to modify this file:

    app/code/core/Mag/Catalog/Block/Product/New.php

    Find this line:

    const DEFAULT_PRODUCTS_COUNT = 5;

    and change the number to whatever you’d like (don’t make it too big for best performance).

    It’s one of the extremely rare cases where modifying a core file is not a big deal.

    I hope this helps!

    +1 Votes Thumb up 1 Votes Thumb down 0 Votes



    • Harney on Jun 07, 2010 Reply

      Thank you for your answer.
      If I write : const DEFAULT_PRODUCTS_COUNT = 10; for example.
      The main problem is that 10 product are displayed on the same line.
      We would like to display 5 product by range (2 ranges of 5 products) and not 10 product on the same range.
      How could I make that?
      I suppose I must write DEFAULT_PRODUCTS_COUNT = 10; in new.php and then write something else in the new.phtml of my template but I don’t know how since this new.phtml is written with table (see code in my first post).

      Thank you very much for your help.

      0 Votes Thumb up 0 Votes Thumb down 0 Votes



  3. Harney on Jun 07, 2010 Reply

    Here is how we would like to display our new product list :
    http://www.enviedecafe.com

    0 Votes Thumb up 0 Votes Thumb down 0 Votes


Answer Question