Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 3
Home page products using layout XML
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

Hi all,

I am trying to update my home page, but rather than post the product block code into the actual content box, I would like to use the Layout Update XML section of the CMS page (under Custom Design) to post the following code:

<reference name="content">
<
block type="catalog/product_list" category_id="21" template="catalog/product/list.phtml"></block>
</
reference>

The problem is that I receive the error:

Fatal error: Call to a member function getProductCollection() on a non-object in site_root/app/code/core/Mage/Catalog/Model/Layer.php on line 40

However, everything works if I simply paste {{block type="catalog/product_list" category_id="21" template="catalog/product/list.phtml"}} into the content box. The reason I want to use the XML Update facility is because i would like to eventually use a custom layout box (which currently works well in the category pages).

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

Hmmm, no replies.

Please can somebody give some feedback on this?

All I want to know is why when I add the same code into Update XML doesn’t it do the same thing as when in the main content text area?

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

I’m also intressted in this question, I’m trying to add custom attributes to the front of my shop. Problem is that I’ve no clue where to put the appropriate XML config. It doesn’t load the catalog.xml file appearenlty, or does it? I’m abit confused here so any help would be appriciated. The XML code that I speak of would look like this in the catalog.xml file:

<reference name="content">
          <
block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <
block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                    <
action method="addAttribute"><code>myAttribute_1</code></action>
                    <
action method="addAttribute"><code>myAttribute_2</code></action>
                    <
action method="addAttribute"><code>myAttribute_3</code></action>
                    <
action method="addAttribute"><code>myAttribute_4</code></action>
         </
block>
            </
block>
</
reference>
 
Magento Community Magento Community
Magento Community
Magento Community
 
pauljg1
Sr. Member
 
Avatar
Total Posts:  179
Joined:  2008-02-22
 

I posted the same thing ages ago and have had no reponse. rasberry I dont think they like the U.K LOL

 
Magento Community Magento Community
Magento Community
Magento Community
 
clorne
Sr. Member
 
Total Posts:  236
Joined:  2008-01-10
London
 

Bockbertil - You may well have tried this already but clearing/refreshing magento cache should reload your xml layout files

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

Hey all,

Well it’s quite frustrating. This is actually the first set of replies I have had to anything I’ve posted and one of my posts was reporting a probable bug that could affect all search engine results!

Bockbertil, I believe too that the catalog.xml files doesn’t get loaded, but have still not had time to get any further. I wonder if we’ll ever know!!??!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

OK well it seems that it’s pretty hard to get a response on the forums which is a shame. I want to bring this up again as I need it to to work and it seems bizarre that it doesn’t:

If I add the following in the pages content box via the admin then it all work fine:

{{block type="catalog/product_list" category_id="21" template="catalog/product/list.phtml"}}

But I get an error if I change the default content in cms.xml:

<reference name="content">
            <
block type="catalog/product_list" name="product_list" category_id="21" template="catalog/product/list.phtml" />
</
reference>
Can anyone shine a light on this?
 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

I have finally resolved it!!!

Basically I here is what I have amended in the cms.xml file:

<reference name="content">
    <
block type="catalog/category_view" category_id="21" name="category.products" template="catalog/category/view.phtml">
        <
block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"></block>
    </
block>
</
reference>

21 is the category ID of my site’s root category. So the first block sets the category, I was trying to set it using the inner block which is what you would do from within a content block.

 
Magento Community Magento Community
Magento Community
Magento Community
 
finch8243
Sr. Member
 
Total Posts:  79
Joined:  2007-08-31
 

@Wiseguy—nice!  I know you’ve been frustrated that no one responds, but that’s probably because we were all as confused as you.  I’ve been watching this thread for a while wondering why it didn’t work for me.  Now I know.  thanks.

D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 
finch8243 - 28 April 2008 09:05 AM

@Wiseguy—nice!  I know you’ve been frustrated that no one responds, but that’s probably because we were all as confused as you.  I’ve been watching this thread for a while wondering why it didn’t work for me.  Now I know.  thanks.

D

Cheers finch8243, just pleased that it’s working!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

19700 update has stopped this working!

Hmph. This has stopped working now that I have upgraded to the latest release v.1.0.19700!!! Now getting:

Fatal error: Call to a member function getMetaTitle() on a non-object in /site_root/app/code/core/Mage/Catalog/Block/Category/View.php on line 38

If I go to the page that is the culprit apparently (/app/code/core/Mage/Catalog/Block/Category/view.php) I think I can see where the problem is. The error is thrown by the protected method _prepareLayout() when it tries this line:

if ($title $this->getCurrentCategory()->getMetaTitle()) {

So I tried to see if the current category has anything assigned using:

die($this->getCurrentCategory());
if (
$title $this->getCurrentCategory()->getMetaTitle()) {

Nothing is returned, hence why the error comes about I think. The problem is I’m not sure which part of the software sets up the object… anyone got any thoughts?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 

Bump!!!

Has anyone else been getting this problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JSTRAT
Jr. Member
 
Total Posts:  16
Joined:  2008-05-06
 

Yup I have hit this problem as well. Has a bug report been entered on this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Guru
 
Avatar
Total Posts:  336
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 

I’m trying to add attributes to a product listing on the front page (CMS).  Has anyone else here managed to do that?

I posted my question here:
How to add Attributes to display in CMS products listing?
http://www.magentocommerce.com/boards/viewthread/9599/

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
corbykissler
Member
 
Total Posts:  39
Joined:  2008-05-14
 

I get the same problem with some code I’m working on.  And your assessment seems correct - that it is caused by referencing a collection with nothing in it.

Gee - it’s been more than 2 months and no one from Magento has replied . . .  big shocker . .

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wiseguy Digital
Member
 
Avatar
Total Posts:  61
Joined:  2007-09-17
Bristol, UK
 
corbykissler - 18 June 2008 04:52 AM

I get the same problem with some code I’m working on.  And your assessment seems correct - that it is caused by referencing a collection with nothing in it.

Gee - it’s been more than 2 months and no one from Magento has replied . . .  big shocker . .

Yeah, it’s really frustrating. I ended up working around the problem by creating a horrible hash of templates, custom extensions and the like, when really this should be easy. I think now though I may instead have created my own class in /app/code/local and tried to fix the problem, so you could maybe look at that if you know how?

Best of luck!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3