3

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();

2 Answers 2

9

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>
3
  • so i have added the adjustments and i keep getting Parse error: syntax error, unexpected end of file in /home/fileserver/public_html/app/design/frontend/rwd/default/template/catalog/layer/state.phtml on line 67
    – Lawrence
    May 20, 2014 at 19:14
  • @Lawrence If you're getting a parse error that means you put something in the file that's invalid PHP code, around line 67 May 21, 2014 at 1:20
  • @Lawrence I'm not sure how to help you more here without seeing the actual file you applied the patch to, but as Alan mentioned, something in that file is invalid PHP code. I do know that the patch I posted results in a file with valid syntax when applied to the core file with no modifications, but beyond that I can't say.
    – davidalger
    May 21, 2014 at 13:57
0

I just had the same issue. I had issued git pull to copy the files of my new theme into a local machine, admin->configuration->design and I recieved the same error as you. What was the problem ...

I had simply forgotten to purge the cache. In the magento_home/var/cache directory, delete all the subfolders. I hope this helps someone else with the problem too.

Your Answer

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

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