Magento Fatal error: calling the member function getSortedChildren () for an object without an object

I installed Magento CE 1.9 and got an error after calling the Directory on the main page. The problem is related to list.phtml .

ERROR: Fatal error: calling member function getSortedChildren () is not an object in mageinc \ application \ design \ interface \ RWD \ default \ template \ directory \ product \ list.phtml on line 74

I did not change anything after installation, and it seems that this problem arose with the release of Magento 1.9.

The problem arises for both the list view and the grid on the Catalog page, because it is called for both views.

Is there a better solution to solve this problem?

+6
source share
6 answers

you just need to remove the method ->getSortedChildren(); line 134

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

so you have

 $_nameAfterChildren = $this->getChild('name.after'); 
+4
source

Add these lines to the block section layout 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"/> 
+2
source

Replace the code with:

 <?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 shown in: https://magento.stackexchange.com/questions/20984/show-products-on-homepage-magento-1-9/20996#20996?newreg=c5c83466c28d45259ed36642cfe0a382

+1
source

Edit this file app / design / frontend / rwd / default / template / catalog / product / list.phtml Add this code in 73 and 135 lines

  <?php if(!empty($nameAfter = $this->getChild('name.after'))): ?> 

immediately before:

  $_nameAfterChildren = $nameAfter->getSortedChildren(); 

and add this code on lines 82 and 144

  <?php endif; ?> 

right after

  <?php endforeach; ?> 
0
source

Pass TeT's solution will throw the PHP error “PHP Fatal error: cannot use the return value of the method in the context of the record”, because PHP has no concept of emptiness. It is better to use <?php if($this->getChild('name.after')): ?> That would not throw an error.

0
source

Hi guys, I had the same problem, but that was because I did not copy all the files from the application / default / default for the application image / yourTheme / by default

I did not have enough files in the default directory. From my understanding - all files need to be copied.
/Etc.
/Layout
/Local
/Template

-1
source

All Articles