Banner Image
Banner Image
Banner Image

Magento SetColumnCount Based on layout Selection – PHTML

I was worked lot of project for this layout based columncount on Magento Product listed page. But all time i was used only the XML solution. But that won’t work with multiple layout which is selected by admin on category layout section.

Now i can show the simple method to fix that problem on layout selection.

Go to the list.phtml file on your magento theme file.

There you can commend this line

[php]
$pageLayoutTemplate = $this->getLayout()->getBlock(‘root’)->getTemplate();

switch ($pageLayoutTemplate) {
case ‘page/1column.phtml’:
$_columnCount = 5;
break;

case ‘page/2columns-left.phtml’:
$_columnCount = 4;
break;

case ‘page/2columns-right.phtml’:
$_columnCount = 4;
break;

case ‘page/3columns.phtml’:
$_columnCount = 3;
break;

default:
$_columnCount = 4;
break;
}
[/php]

Blog

15/10/2025
Building a Robust eCommerce Website with Magento: A Complete Guide by Sharesoft
In today’s fast-moving digital world, building a strong online presence is more than just having…
11/10/2025
Why Custom Shopify Website Development Is the Key to Building a Scalable eCommerce Brand
Introduction: The Rise of Shopify in Modern eCommerce In today’s fast-paced digital marketplace, where customer…
07/10/2025
Shopify Development for Enterprise eCommerce: A Complete Guide for Large-Scale Brands
When your business crosses a certain scale—many SKUs, high order volume, multiple sales channels, global…
03/10/2025
Shopify Theme Development vs Custom Shopify Website Design: What’s Best for Your Business?
Introduction When launching or upgrading an online store, one of the most important decisions you’ll…

Stay Ahead in Digital Innovation

Looking for expert tips, industry insights, and strategies to boost your digital presence? Subscribe to Sharesoft Technology’s weekly LinkedIn newsletter!