0

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.

1 Answer 1

0

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();
4
  • I tried the above code and it is displaying a total number of products from category no 4. What if i know the id of lp_brand which in this case is "47".
    – haver15
    Commented Feb 15, 2015 at 13:54
  • @haver15 I have edited my code. Try again.
    – MagePsycho
    Commented Feb 15, 2015 at 14:01
  • I just tried the code, and it is returning 0 results. But for this case I know there should be "1" particular product in this category wehere lp_brand id is 47.
    – haver15
    Commented Feb 15, 2015 at 14:08
  • My bed, above code @MagePsycho is correct. Thank you very much. :)
    – haver15
    Commented Feb 15, 2015 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.