Dynamically change no. of products

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

 

Hello,

I am new to magento. I want to do like if 1col layout then 4products 2col layout then 3products and 3col layout then 2 products.

For that I have make change in catalog.xml

<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<!-- <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/su.phtml</template></action> -->

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>

</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>3</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>3</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>2</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
</reference>

but it is not working. Also How can we know with handler is reflecting content?

In Advance Thanks
Rachna Shah

 

Hi,

In file app/design/frontend/default/your_theme/template/catalog/product/list.phtml, you can go to line 91 (In Grid Mode) and add this code:

$_collectionSize $_productCollection->count();
$_columnCount $this->getColumnCount();

$pageTemplate $this->getLayout()->getBlock('root')->getTemplate();

if(
$pageTemplate == 'page/3columns.phtml'{
        $_columnCount 
2;
else if($pageTemplate == 'page/2columns-left.phtml' || $pageTemplate == 'page/2columns-right.phtml'{
        $_columnCount 
3;
else if($pageTemplate == 'page/1column.phtml'{
        $_columnCount 
4;
}
...

Hope you will succeed.

 Signature 

MageStore - Magento Extensions and Templates: Affiliate, Store pickup, Gift-wrap, Gift voucher, 1stepcheckout, Auction…
Social voice - to build the best feedback system. Take the standard edition for free!

`Reply Or Comment!
Please LogIn to Reply!