第二级别的回声计数中的getProductCount()打印出0,我尝试不同的方式,但我没想到像法师得到收集等,我没有找到任何解决方案在这个问题
<?php
$_category = $this->getCurrentCategory();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
?>
<?php foreach ($collection as $cat):?>
<?php
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$_img = $cur_category->getThumbnailUrl();
?>
<div class="grid_4">
<div class="mineContent_grid_4">
<dl>
<dt>
<a href="<?php echo $helper->getCategoryUrl($cat);?>">
<?php echo $cat->getName();?>
<img src="<?php echo $_img?>" title="<?php echo $cat->getName();?>" width="173" height="208"/>
</a>
</dt>
<?php $childLevel2Category = Mage::getModel('catalog/category')->getCategories($cat->entity_id);
?>
<dd>
<ol>
<?php foreach ($childLevel2Category as $catLevel2) { ?>
<?php
$cur_category2 = Mage::getModel('catalog/category')->load($cat->getId());
$count = $cur_category2->getProductCount();
?>
<li> <a href="<?php echo $helper->getCategoryUrl($catLevel2);?>"><?php echo $catLevel2->getName();?> <span>(<?php echo …Run Code Online (Sandbox Code Playgroud) 此代码仅适用于非锚类别 - 如何获得锚类别的产品计数?
<div class="grid_16"><h1 class="highlight pageTitle"><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?>
<span>
(<?php echo $_category->getProductCount() ?>)
</span>
</h1></div>
Run Code Online (Sandbox Code Playgroud)