Question

I'm using bellow code for displaying the amount of product/s in specific category on my home page:

<?php 
                    $products_count = Mage::getModel('catalog/category')->load(4)
                    ->getProductCount();
                    echo($products_count);
                    ?>

Where 4 is the number/ID of my specific category.

Now I would like to display the amount of attributes with name "lp_brand" from this specific category.

Thank you in advance.

Was it helpful?

Solution

Try:

<?php
$products = Mage::getModel('catalog/category')->load(4)
    ->getProductCollection()
    ->addAttributeToSelect('*')
    //->addAttributeToFilter('status', 1)
    //->addAttributeToFilter('visibility', 4)
    ->addAttributeToFilter('lp_brand', array('eq' => 47));
echo $products->getSize();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top