How to resolve the Error “Call to a member function getChildren() on null” The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraGet subcategories of parent category when FLAT categories enabledLayered navigation on homepage in magento 1.9 Call to a member function load() on a non-object in Error OccuredHow would I add “Brand” to the layered navigation without having to add the attribute to the productHow To call 'sidebar.phtml' in cart pop upHow to set dynamic width for the ul by postitioning it properly?How to align the ul li perfectly columnwise?When i call $this->loadLayout(); ite return error on catalogsearchGetting error : Fatal error: Call to a member function setLayer() on a non-object inMagento 1: Custom layer block not showing categoriesjQuery got no function after AJAX call
What force causes entropy to increase?
Are spiders unable to hurt humans, especially very small spiders?
"is" operation returns false even though two objects have same id
Identify 80s or 90s comics with ripped creatures (not dwarves)
How to read αἱμύλιος or when to aspirate
Do I have Disadvantage attacking with an off-hand weapon?
Is every episode of "Where are my Pants?" identical?
What can I do if neighbor is blocking my solar panels intentionally?
Is this wall load bearing? Blueprints and photos attached
Why did Peik Lin say, "I'm not an animal"?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
What was the last x86 CPU that did not have the x87 floating-point unit built in?
Does Parliament hold absolute power in the UK?
One-dimensional Japanese puzzle
How do I design a circuit to convert a 100 mV and 50 Hz sine wave to a square wave?
What happens to a Warlock's expended Spell Slots when they gain a Level?
Can we generate random numbers using irrational numbers like π and e?
how can a perfect fourth interval be considered either consonant or dissonant?
Why can't devices on different VLANs, but on the same subnet, communicate?
Fixing different display colors within string
ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?
Define a list range inside a list
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
"... to apply for a visa" or "... and applied for a visa"?
How to resolve the Error “Call to a member function getChildren() on null”
The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraGet subcategories of parent category when FLAT categories enabledLayered navigation on homepage in magento 1.9 Call to a member function load() on a non-object in Error OccuredHow would I add “Brand” to the layered navigation without having to add the attribute to the productHow To call 'sidebar.phtml' in cart pop upHow to set dynamic width for the ul by postitioning it properly?How to align the ul li perfectly columnwise?When i call $this->loadLayout(); ite return error on catalogsearchGetting error : Fatal error: Call to a member function setLayer() on a non-object inMagento 1: Custom layer block not showing categoriesjQuery got no function after AJAX call
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I wish to display the level1 and level2 subcategories of current active category in layered navigation in list page. So I gave the below code in catalog/category/view.phtml :
<div class="sidebar-block">
<?php
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
?>
<div class="block-content clearfix">
<ul class="subcategories">
<?php foreach ($categories as $category): ?>
<?php
foreach ($children as $child)
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = 'level'. $childLevel;
$_hasChildren = ($child->hasChildren()) ? 'has-children' : '';
$html .= '<li '. $this->_getRenderedMenuItemAttributes($child) .'>';
$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
if (!empty($childrenWrapClass))
$html .= '<div class="'. $childrenWrapClass .'">';
$nextChildLevel = $childLevel + 1;
if (!empty($_hasChildren))
$html .= '<ul class="level'. $childLevel .'">';
$html .= $this->render($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass))
$html .= '</div>';
$html .= '</li>';
$counter++;
?>
<?php endforeach; ?>
</ul>
</div>
</div>
am getting the error like Call to a member function getChildren() on null
How to resolve this? What should be done.Or is this approach wrong? Help please. am stuck.
layered-navigation sidebar submenu
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I wish to display the level1 and level2 subcategories of current active category in layered navigation in list page. So I gave the below code in catalog/category/view.phtml :
<div class="sidebar-block">
<?php
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
?>
<div class="block-content clearfix">
<ul class="subcategories">
<?php foreach ($categories as $category): ?>
<?php
foreach ($children as $child)
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = 'level'. $childLevel;
$_hasChildren = ($child->hasChildren()) ? 'has-children' : '';
$html .= '<li '. $this->_getRenderedMenuItemAttributes($child) .'>';
$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
if (!empty($childrenWrapClass))
$html .= '<div class="'. $childrenWrapClass .'">';
$nextChildLevel = $childLevel + 1;
if (!empty($_hasChildren))
$html .= '<ul class="level'. $childLevel .'">';
$html .= $this->render($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass))
$html .= '</div>';
$html .= '</li>';
$counter++;
?>
<?php endforeach; ?>
</ul>
</div>
</div>
am getting the error like Call to a member function getChildren() on null
How to resolve this? What should be done.Or is this approach wrong? Help please. am stuck.
layered-navigation sidebar submenu
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I wish to display the level1 and level2 subcategories of current active category in layered navigation in list page. So I gave the below code in catalog/category/view.phtml :
<div class="sidebar-block">
<?php
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
?>
<div class="block-content clearfix">
<ul class="subcategories">
<?php foreach ($categories as $category): ?>
<?php
foreach ($children as $child)
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = 'level'. $childLevel;
$_hasChildren = ($child->hasChildren()) ? 'has-children' : '';
$html .= '<li '. $this->_getRenderedMenuItemAttributes($child) .'>';
$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
if (!empty($childrenWrapClass))
$html .= '<div class="'. $childrenWrapClass .'">';
$nextChildLevel = $childLevel + 1;
if (!empty($_hasChildren))
$html .= '<ul class="level'. $childLevel .'">';
$html .= $this->render($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass))
$html .= '</div>';
$html .= '</li>';
$counter++;
?>
<?php endforeach; ?>
</ul>
</div>
</div>
am getting the error like Call to a member function getChildren() on null
How to resolve this? What should be done.Or is this approach wrong? Help please. am stuck.
layered-navigation sidebar submenu
I wish to display the level1 and level2 subcategories of current active category in layered navigation in list page. So I gave the below code in catalog/category/view.phtml :
<div class="sidebar-block">
<?php
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
?>
<div class="block-content clearfix">
<ul class="subcategories">
<?php foreach ($categories as $category): ?>
<?php
foreach ($children as $child)
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = 'level'. $childLevel;
$_hasChildren = ($child->hasChildren()) ? 'has-children' : '';
$html .= '<li '. $this->_getRenderedMenuItemAttributes($child) .'>';
$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
if (!empty($childrenWrapClass))
$html .= '<div class="'. $childrenWrapClass .'">';
$nextChildLevel = $childLevel + 1;
if (!empty($_hasChildren))
$html .= '<ul class="level'. $childLevel .'">';
$html .= $this->render($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass))
$html .= '</div>';
$html .= '</li>';
$counter++;
?>
<?php endforeach; ?>
</ul>
</div>
</div>
am getting the error like Call to a member function getChildren() on null
How to resolve this? What should be done.Or is this approach wrong? Help please. am stuck.
layered-navigation sidebar submenu
layered-navigation sidebar submenu
asked Jun 18 '16 at 11:56
RamyaRamya
6981236
6981236
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If error says that you call function on null, first thing I would do is to check variable $category or $menuTree with print_r() or var_dump - maybe they are in fact null, which means the objects which should be under these varaibles or you think they should be, in fact are not assigned to them. Later if you detect which and if varaible is empty you should figure out way and then you can perform some changes in your code to get what you've planned.
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f121644%2fhow-to-resolve-the-error-call-to-a-member-function-getchildren-on-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If error says that you call function on null, first thing I would do is to check variable $category or $menuTree with print_r() or var_dump - maybe they are in fact null, which means the objects which should be under these varaibles or you think they should be, in fact are not assigned to them. Later if you detect which and if varaible is empty you should figure out way and then you can perform some changes in your code to get what you've planned.
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
add a comment |
If error says that you call function on null, first thing I would do is to check variable $category or $menuTree with print_r() or var_dump - maybe they are in fact null, which means the objects which should be under these varaibles or you think they should be, in fact are not assigned to them. Later if you detect which and if varaible is empty you should figure out way and then you can perform some changes in your code to get what you've planned.
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
add a comment |
If error says that you call function on null, first thing I would do is to check variable $category or $menuTree with print_r() or var_dump - maybe they are in fact null, which means the objects which should be under these varaibles or you think they should be, in fact are not assigned to them. Later if you detect which and if varaible is empty you should figure out way and then you can perform some changes in your code to get what you've planned.
If error says that you call function on null, first thing I would do is to check variable $category or $menuTree with print_r() or var_dump - maybe they are in fact null, which means the objects which should be under these varaibles or you think they should be, in fact are not assigned to them. Later if you detect which and if varaible is empty you should figure out way and then you can perform some changes in your code to get what you've planned.
answered Jun 18 '16 at 13:51
Bartosz KubickiBartosz Kubicki
1,4401037
1,4401037
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
add a comment |
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
can you suggest a way to display level 1 and level 2 category in layered navigation in list page?
– Ramya
Jun 20 '16 at 10:13
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
I am not actually working on Magento 1, I don't have it even installed in raw copy, so I cannot help you now. I am sorry :(
– Bartosz Kubicki
Jun 20 '16 at 10:43
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f121644%2fhow-to-resolve-the-error-call-to-a-member-function-getchildren-on-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown