Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the number of upsell products in magento?

I created a store in magento. I want to increase the number of upsell products in the product description page.Currently it is showing 4 products in front and other products after clicking next link. I want to change it to 5.

like image 845
David Avatar asked Dec 21 '22 20:12

David


1 Answers

The upsell block is invoked in the layout by some layout update XML in catalog.xml, and the limit is being imposed on/evaluated by this catalog/product_list_upsell (aka Mage_Catalog_Block_Product_List_Upsell block instance.

<catalog_product_view translate="label">
    <!-- snip -->
    <reference name="content">
        <!-- snip -->
        <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
            <action method="setColumnCount"><columns>4</columns></action>
            <action method="setItemLimit"><type>upsell</type><limit>4</limit></action>
        </block>
        <!-- snip -->
    </reference>
    <!-- snip -->
</catalog_product_view>

You can use the above information and your layout's local.xml (create it if you don't already have it) to overwrite the item_limit value:

<catalog_product_view>
    <reference name="product.info.upsell">
        <action method="setItemLimit"><type>upsell</type><limit>5</limit></action>
        <!--
        if you want them all rendered on one line, change the column_count as well:
        <action method="setColumnCount"><columns>5</columns></action>
        -->
    </reference>
</catalog_product_view>

More more information, see the Mage_Catalog_Block_Product_List_Upsell class definition.

like image 188
benmarks Avatar answered Jan 06 '23 01:01

benmarks