Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: how do you change the number of product columns based upon page layout?

Tags:

magento

I know that in catalog.xml this line effects all layouts:

   <action method="setColumnCount"><columns>5</columns></action> 

But I want to change the number of columns based upon specific page layouts, i.e.: 2columns with left bar, 3 columns, etc.

This is what someone said to do but I am not sure I was adding the update tag in the right spot because it didn't seem to work. Also if you read the comments they say once you turn caching back on it breaks it: http://www.lotusseedsdesign.com/blog/change-grid-view-column-4-product-listing

So does anyone know how to use the addColumnCountLayoutDepend method or any other way to change the number of columns on the product grid specific to the page layout?

like image 597
Christina Avatar asked Feb 25 '11 17:02

Christina


People also ask

How do I change the layout of a product detail page in Magento 2?

In order to apply custom layout updates for your product pages, you'll need to put an . XML file in a specified folder ( app/design/frontend/<Vendor>/<Theme>/Magento_Catalog/layout/ ). The layout update from that . XML file will then appear under Custom Layout Update as a selectable option.


1 Answers

For sub category page, in app/design/frontend/Your Interface/layout/catalog.xml change columns value the following line :

<action method="setColumnCount"><columns>4</columns></action>

For root category page, in app/design/frontend/Your Interface/template/catalog/product/list.phtml find the following code in "Grid Mode" section and change with appropiate value :

<?php $_columnCount = $this->getColumnCount(); ?>

like

<?php $_columnCount = 4; ?>
like image 111
Oğuz Çelikdemir Avatar answered Sep 29 '22 01:09

Oğuz Çelikdemir