Magento – magento CE 1.9 responsive theme error

ce-1.9.0.1layered-navigationrwdrwd-theme

I Just updated to magento 1.9 and I really love the responsive theme. The colors, the look, and everything about it.

I really would love to keep it but I am keep getting:

Fatal error: Call to a member function getSortedChildren() on a
non-object in
/home/fileserver/public_html/app/design/frontend/rwd/default/template/catalog/layer/state.phtml
on line 36

by were the side navigation, where all the sub categories are.

Coding is still new to me so any help would be really appreciated!

35: $_filters = $this->getActiveFilters();
36: $_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChildren();

Best Answer

If you pop open the app/design/frontend/rwd/default/layout/catalog.xml file you'll find this:

76. <block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml">
77.     <block type="core/text_list" name="catalog.leftnav.state.renderers" as="state_renderers" />
78. </block>

As you can see, there is an added block state_renderers which the template the PHP error is turning up in is relying on being present. Now, it would have been much better for this template to verify the result to the getChild() call was not null before doing anything with it, but unfortunately it doesn't. Maybe the handful of places this occurs in the new rwd/default templates will have this resolved in the next version of EE 1.14. :)

I would suggest making sure your catalog.xml layout includes the new child blocks found in the core. If you have other blocks using this template, they'll need a similar child block inserted into their layout.

Alternatively, you could alter the template within your custom theme to implement a check for the block before it uses it like this (disclaimer: this patch is untested, use at your own risk):

diff --git a/app/design/frontend/rwd/default/template/catalog/layer/state.phtml b/app/design/frontend/rwd/default/template/catalog/layer/state.phtml
index 0b90407..e8998fd 100644
--- a/app/design/frontend/rwd/default/template/catalog/layer/state.phtml
+++ b/app/design/frontend/rwd/default/template/catalog/layer/state.phtml
@@ -33,16 +33,17 @@
 ?>
 <?php
 $_filters = $this->getActiveFilters();
-$_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChildren();
+$_renderers = $this->getParentBlock()->getChild('state_renderers');
 ?>
 <?php if(!empty($_filters)): ?>
 <div class="currently">
     <p class="block-subtitle"><?php echo $this->__('Currently Shopping by:') ?></p>
     <ol>
     <?php foreach ($_filters as $_filter): ?>
+        <?php if ($_renderers != null): ?>
         <?php
         $_rendered = false;
-        foreach ($_renderers as $_rendererName):
+        foreach ($_renderers->getSortedChildren() as $_rendererName):
             $_renderer = $this->getParentBlock()->getChild('state_renderers')->getChild($_rendererName);
             if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_filter)):
                 $_renderer->setFilter($_filter);
@@ -67,6 +68,7 @@ $_renderers = $this->getParentBlock()->getChild('state_renderers')->getSortedChi
             <span class="label"><?php echo $this->__($_filter->getName()) ?>:</span> <span class="value"><?php echo $this->stripTags($_filter->getLabel()) ?></span>
         </li>
         <?php endif; ?>
+        <?php endif; ?>
     <?php endforeach; ?>
     </ol>
 </div>
Related Topic