gpt4 book ai didi

Magento - 停止在 anchor 类别中显示子产品

转载 作者:行者123 更新时间:2023-12-02 13:31:41 36 4
gpt4 key购买 nike

在 anchor 类别页面上,我尝试仅显示直接包含在该类别中的产品。我不想显示子类别的产品,在这种情况下不合适。我确实需要过滤当前类别中的产品,所以我需要分层导航,这就需要一个 anchor 类别。

最初我想过滤 view.phtml 模板中的产品,但这仅过滤 View 中的产品,并不是一个明智的答案。当我这样做时,我的页面上会出现很大的空白,其中存在子产品,但根本没有显示。并且产品计数(例如“117 种产品中的 1-12 种”)“不正确”。

据我所知,这将需要核心重写。可能是索引过程。我真的不知道从哪里开始重写,而且我确信它会相当复杂。

我的假设有错误吗?您已经解决这个问题了吗?

最佳答案

转到app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php

复制到app/code/local/Mage/Catalog/Model/Resource/Product/Collection.php

找到函数addCategoryFilter(,在这里你可以找到代码

 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
{
$this->_productLimitationFilters['category_id'] = $category->getId();
/* start to comment here
if ($category->getIsAnchor()) {
unset($this->_productLimitationFilters['category_is_anchor']);
} else {
$this->_productLimitationFilters['category_is_anchor'] = 1;
}*/
/* new line */

$this->_productLimitationFilters['category_is_anchor'] = 1;

if ($this->getStoreId() == Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID) {
$this->_applyZeroStoreProductLimitations();
} else {
$this->_applyProductLimitations();
}

return $this;
}

关于Magento - 停止在 anchor 类别中显示子产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22990622/

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