3

I'm loading all products using the product collection resource model.

$_categoryId = $this->getCategoryId();

$_productCollection = Mage::getResourceModel('catalog/product_collection')
        ->addMinimalPrice()
        ->addFinalPrice()
        ->addTaxPercents()
        ->addCategoryFilter(Mage::getModel('catalog/category')->load($_categoryId))
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('status', 1)
        ->addAttributeToFilter('visibility', 4);

I'm however not able to display the minimal price of grouped products using for example.

echo $_productCollection->getFirstItem()->getMinimalPrice();

This does work for simple products. This seems to be related to the fact that this is a core/template block type and not a catalog/product_list block. But using catalog/product_list is not an option due to other reasons.

2

If you update your code so it does no just select * but instead use the catalog config attributes then your code works for all product types.

Mage::getSingleton('catalog/config')->getProductAttributes()

Your code should look like.

$_categoryId = $this->getCategoryId();

$_productCollection = Mage::getResourceModel('catalog/product_collection')
    ->addMinimalPrice()
    ->addFinalPrice()
    ->addTaxPercents()
    ->addCategoryFilter(Mage::getModel('catalog/category')->load($_categoryId))
    ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
    ->addAttributeToFilter('status', 1)
    ->addAttributeToFilter('visibility', 4);

In this case the correct minimal prices will be loaded for each type of product.

  • 1
    Took a while to come back to this.. but that did it. Thank you! – Paul van Schayck Oct 16 '13 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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