Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 1-如何使每行的产品数量不同,每个页面布局也不同_Magento_Magento 1 - Fatal编程技术网

Magento 1-如何使每行的产品数量不同,每个页面布局也不同

Magento 1-如何使每行的产品数量不同,每个页面布局也不同,magento,magento-1,Magento,Magento 1,你好 ^这篇文章是为所有页面设置每行4个产品的指南。 我想为每个页面布局设置不同数量的产品 目标: 3列页面布局的每行3个产品 2列的每行4种产品 1列的每行5种产品 请给出每行定制产品的说明 感谢您在app/design/frontend/yourtheme/default/template/catalog/product/list.phtml(如果您没有从app/design/frontend/base/default/template/catalog/product/list.pht

你好

^这篇文章是为所有页面设置每行4个产品的指南。

我想为每个页面布局设置不同数量的产品

目标:

  • 3列页面布局的每行3个产品
  • 2列的每行4种产品
  • 1列的每行5种产品
请给出每行定制产品的说明


感谢您在app/design/frontend/yourtheme/default/template/catalog/product/list.phtml(如果您没有从app/design/frontend/base/default/template/catalog/product/list.phtml复制,请创建它)中使用,并替换该行:

<?php // Grid Mode ?>

<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>



对不起,我对代码不是很友好-在我复制它之后,它就不起作用了。你能解释一下我需要使用什么标签或其他什么吗?谢谢你,我在上面扩展了我的答案,希望能让它更明确。你是最好的!!一切顺利,非常感谢!
<?php $_collectionSize = $_productCollection->count() ?>

<?php

// Get the layout's page template
$pageLayoutRootTemplate = $this->getLayout()->getBlock('root')->getTemplate();
// Set the column count based on the layout template used
switch ($pageLayoutRootTemplate) {
    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 = 3;
        break;
}
// comment normal line out $_columnCount = $this->getColumnCount(); ?>

<?php $i=0; foreach ($_productCollection as $_product): ?>