1

I'll show my category list in a static block

<div>{{block type="catalog/product_list" category_id="488" template="catalog/product/list.phtml"}}</div>

No problem. But now I'm try to use the upsell.phtml- Template with

<div>{{block type="catalog/product_list" category_id="488" template="catalog/product/list/upsell.phtml"}}</div>

and I'll get these PHP Error. I'm not a PHP-developer, can you help me?

Fatal error: Call to a member function getItems() on a non-object in /var/www/.../catalog/product/list/upsell.phtml on line 1

and there's the standard Magento Code (upsell.phtml)

<?php if(count($this->getItemCollection()->getItems())): ?>

I have no idea what's wrong?!

0

You are attempting to only change the template, not the block type. If you check the block Mage_Catalog_Model_Product_list you will see that there is no getItemCollection method on it, therefore this call will return null (or possibly an empty string, can't remember off the top of my head). This results in your template attempting to call getItems on that null/empty string. As @Keyul suggests the solution would be to use the block type that the upsell.phtml file is associated with, which is Mage_Catalog_Model_Product_List_Upsell. This block has the method getItemCollection and thus returns the collection expected in the template.

{{block type="catalog/product_list_upsell" category_id="488" template="catalog/product/list/upsell.phtml"}}
1

you can try below one

{{block type="catalog/product_list_upsell" category_id="488" template="catalog/product/list/upsell.phtml"}}

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.