我研究了关于 Magento 1.9 未将类别添加到主页的问题。所以,我最终添加了:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list.phtml"}}

到首页内容。它也显示在主页上但是:5 种产品中仅包含 1 种。这是为什么?可以改变吗?

我对 Magento 还很陌生,在布局方面我没有改变任何东西。我看过这个帖子: 同样的问题, ,但是没有人回答(我也无法评论),我已经关注了 这些步骤 - 但这一切都不起作用。

有帮助吗?

解决方案

您是否使用来自Magento 1.9的RWD主题?如果是这样,问题可能在目录/产品/ list.phtml模板文件中。

在目录/产品/ list.phtml中,从RWD主题中,以下代码

从线133到140

<?php $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); foreach($_nameAfterChildren as $_nameAfterChildName): $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); $_nameAfterChild->setProduct($_product); ?> <?php echo $_nameAfterChild->toHtml(); ?> <?php endforeach; ?>

和从178线到186

<?php //set product collection on after blocks $_afterChildren = $this->getChild('after')->getSortedChildren(); foreach($_afterChildren as $_afterChildName): $_afterChild = $this->getChild('after')->getChild($_afterChildName); $_afterChild->setProductCollection($_productCollection); ?> <?php echo $_afterChild->toHtml(); ?> <?php endforeach; ?>

如果您在没有子组的布局中添加块,则会导致错误。“。

如果您希望此项工作在主页上,您应该在主题中创建一个新模板,例如目录/产品/ list_home.phtml,并从目录/ product / list.phtml复制代码,但删除代码我指出的线条。然后,您应该在主页块中使用新模板:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list_home.phtml"}}

其他提示

从中删除这些行 catalog/product/list.phtml

<?php
    //set product collection on after blocks
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach($_afterChildren as $_afterChildName):
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        $_afterChild->setProductCollection($_productCollection);
    ?>
    <?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
许可以下: CC-BY-SA归因
scroll top