magento showing wrong product count in category

前端 未结 3 801
甜味超标
甜味超标 2021-01-02 04:32

I have a strange issue and seems many are having the same on internet. Below picture will define my issue and also my magento version is 1.7

3条回答
  •  抹茶落季
    2021-01-02 05:13

    A simple solution to this is go to app/code/core/Mage/Catalog/Model/Category.php

    or it's better to create a local file so that it doesn't effects while magento upgrade. So create app/code/local/Mage/Catalog/Model/Category.php

    In this model create a new function say getFrontentProductCount()

        public function getFrontentProductCount()
    {
        $collection = Mage::getResourceModel('catalog/product_collection')
            ->addCategoryFilter($this);
    Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
    Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
    return $collection->count();
    

    }

    Now go to your template phtml file where you execute your category product count. In general case it's: theme/template/catalog/navigation/left.phtml

    now call the above function as required, like:

     
      getIsActive()): ?>
    1. isCategoryActive($_category)): ?> class="current">htmlEscape($_category->getName()) ?> (getFrontentProductCount() ?>)

提交回复
热议问题