gpt4 book ai didi

magento - 限制主页上显示的产品数量,list.phtml

转载 作者:可可西里 更新时间:2023-11-01 00:00:33 25 4
gpt4 key购买 nike

我试图将主页上某个类别的产品数量限制为 4 个。

我尝试使用的代码是:

{{block type="catalog/product_list" column_count="4" category_id="13" template="catalog/product/list.phtml"}}

以下是我尝试过的一些方法:

num_products="4"
limit = 4, limit="4"
count = 4, count="4"
_productCollection="4"
_productsCount="4"

我复制了一份 list.phtml,认为可能有办法改变它,但找不到办法。

在 pf list.phtml 的最顶部是这段代码:

<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>

在 GridView 下是这样的:

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

关于在 block 或模板文件中限制产品的任何想法?

最佳答案

更快的方法是将 column_count=4 替换为 is_homepage=1

并在 phtml 中添加:

 <?php if($this->getIsHomepage() && $i==4) break; ?>

在此之前:

 <?php if ($i++%$_columnCount==0): ?>

然后你在主页上只有 1 行(如果我想是 4 行)所以总共有 4 个产品

关于magento - 限制主页上显示的产品数量,list.phtml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15281060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com