Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Fatal error: Call to a member function getSortedChildren() on a non-object

I have installed Magento CE 1.9 version and getting error after calling Catalog on Home page. Issue seems to be related with list.phtml.

ERROR : Fatal error: Call to a member function getSortedChildren() on a non-object in mageinc\app\design\frontend\rwd\default\template\catalog\product\list.phtml on line 74

I didn't change anything after installation and it seems this issue came with Magento 1.9 edition.

Issue is occurring for both List and Grid view on Catalog page as it is being called for both views.

Is there any best solution to resolve this issue ?

like image 529
aforankur Avatar asked May 14 '14 11:05

aforankur


3 Answers

you just have to delete the method ->getSortedChildren(); at line 134

$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();

so you have

$_nameAfterChildren = $this->getChild('name.after');
like image 186
user3772023 Avatar answered Nov 04 '22 13:11

user3772023


Add these lines in your block section layouts file

     <block type="core/text_list" name="product_list.name.after" as="name.after"/>
     <block type="core/text_list" name="product_list.after" as="after"/>
like image 36
anwerj Avatar answered Nov 04 '22 15:11

anwerj


Replace the code by:

<?php
$_nameAfter = $this->getChild('name.after');
// New if here
if($_nameAfter):
    $_nameAfterChildren = $_nameAfter->getSortedChildren();
    foreach($_nameAfterChildren as $_nameAfterChildName):
        $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
        $_nameAfterChild->setProduct($_product);
        ?>
        <?php echo $_nameAfterChild->toHtml(); ?>
    <?php endforeach; ?>
<?php endif; ?>

<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after');
if ($_afterChildren):
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach($_afterChildren as $_afterChildName):
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        $_afterChild->setProductCollection($_productCollection);
    ?>
    <?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
<?php endif; ?>

As seen in: https://magento.stackexchange.com/questions/20984/show-products-on-homepage-magento-1-9/20996#20996?newreg=c5c83466c28d45259ed36642cfe0a382

like image 1
Phillipe Rosário Avatar answered Nov 04 '22 13:11

Phillipe Rosário