0

此代码仅适用于非锚类别 - 如何获取锚类别的产品数量?

<div class="grid_16"><h1 class="highlight pageTitle"><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>

        <span>
            (<?php echo $_category->getProductCount() ?>)
        </span>

    </h1></div>
4

2 回答 2

5
$prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category); 

var_dump($prodCollection->count());
于 2012-04-28T07:47:15.610 回答
2

如此处所示:magento 论坛

$category_object = Mage::getModel('catalog/category')->load( CATEGORY_ID ); // If you don't already have one
$total = Mage::getModel('catalog/layer')->setCurrentCategory( $category_object )->getProductCollection()->getSize() 

将显示正确的产品数量

于 2013-07-24T16:03:12.183 回答