0

I need to access the current product collection in teh main page template (in this case 2-columns-left) in order to check whether a certain product exists, and if it does, display a banner advert.

I have tried:

$products = Mage::getModel('catalog/product')->getCollection();

but this loads all products, not just the ones loaded into the product list template.

Is there a way I can access only those products listed in the product view template from the parent template (2-columns-left)?

2
  • Are you trying to find the product collection in list.phtml? Feb 20, 2015 at 11:22
  • No, in 2-columns-left - in terms of the layout the banner appears above the list.phtml in the page
    – matt
    Feb 20, 2015 at 11:24

2 Answers 2

1

You can do:

Mage::registry('current_category')->getProductCollection();

Regards, Diego.

0

Mat, you can use the following code,

$currentCategory = Mage::registry('current_category');
if($currentCategory){
   $products = Mage::getModel('catalog/product')
                ->getCollection($currentCategory);               
}

Hope this helps. Thanks.

Your Answer

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

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