Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Fatal error: Call to a member function count()
 
jonny98002
Jr. Member
 
Total Posts:  27
Joined:  2009-02-16
 

I am actually not sure if this error is from the upgrade or not.  But after I upgraded to 1.3, when I navigate to a sub-sub category from the topnav I get this Error:

Fatal error: Call to a member function count() on a non-object in /app/design/frontend/default/hellosleek/template/catalog/navigation/left.phtml on line 36

Line 36 reads:

<?php if($_categories->count()): ?>

Any Ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zulusek
Jr. Member
 
Total Posts:  12
Joined:  2007-10-08
Czastary
 

I have same problem with mine instalation. Do you have fix for this issue?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonny98002
Jr. Member
 
Total Posts:  27
Joined:  2009-02-16
 

I haven’t found a fix yet.  I did find that I could limit the Top Nav depth in the configuration.  I limited it to 2 and I have avoided the issue.  I am still looking for a fix.

 
Magento Community Magento Community
Magento Community
Magento Community
 
zulusek
Jr. Member
 
Total Posts:  12
Joined:  2007-10-08
Czastary
 

Solution has been found by polish magento user kkkonrad and posted on polish forum yento.pl

Simply change

<?php if($_categories->count()): ?>

to

<?php if(count($_categories)): ?>

For me works great smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
deroguy
Jr. Member
 
Total Posts:  8
Joined:  2009-02-06
 

zulusek,

Thanks for posting that. It fixed my problem too!

Deroguy LOL

 
Magento Community Magento Community
Magento Community
Magento Community
 
hridaya
Member
 
Avatar
Total Posts:  63
Joined:  2009-02-04
Nepal
 

zulusek,

Thanks for posting that. It fixed my problem too!

Hridaya :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jason Millward
Member
 
Total Posts:  59
Joined:  2008-05-03
 

Thanks for posting this solution. Its solved the problem I was having also

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dorgo
Sr. Member
 
Total Posts:  127
Joined:  2008-12-16
 

I was having the same problem. My site view was created from the default one that came with 1.1.8
I compared with the one provided for 1.3.0 and found that line 36

<?php if($_categories->count()): ?>
had been changed to
<?php $_count is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php 
if($_count): ?>

This might be a more complete solution than

<?php if(count($_categories)): ?>

posted above.

 
Magento Community Magento Community
Magento Community
Magento Community
 
firestorm
Jr. Member
 
Total Posts:  6
Joined:  2009-02-11
 
Dorgo - 26 April 2009 08:16 PM

I was having the same problem. My site view was created from the default one that came with 1.1.8
I compared with the one provided for 1.3.0 and found that line 36

<?php if($_categories->count()): ?>
had been changed to
<?php $_count is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php 
if($_count): ?>

This might be a more complete solution than
<?php if(count($_categories)): ?>

posted above.

Thanks Dorgo - and the Polish guy!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Unixversal
Sr. Member
 
Avatar
Total Posts:  80
Joined:  2008-04-23
Cologne, Germany
 

Thx. Worked perfectly for me! After installing aw_blog extension I experienced same error with 1.3.3.2 Version now everything works fine again!

Cheers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rokonboss
Member
 
Avatar
Total Posts:  44
Joined:  2008-11-19
 

<?php $_collectionSize count($listall); ?>

Replace with

<?php $_collectionSize $listall->count(); ?>

it works for me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DrBillNye
Sr. Member
 
Avatar
Total Posts:  96
Joined:  2009-02-07
Boulder, CO
 
zulusek - 07 April 2009 09:28 PM

Solution has been found by polish magento user kkkonrad and posted on polish forum yento.pl

Simply change

<?php if($_categories->count()): ?>

to

<?php if(count($_categories)): ?>

For me works great smile

fixed mine too, thanks zulusek

 
Magento Community Magento Community
Magento Community
Magento Community
 
rakesh946
Jr. Member
 
Total Posts:  2
Joined:  2011-07-18
 

Not working for me in magento1.6.0

<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
rakesh946
Jr. Member
 
Total Posts:  2
Joined:  2011-07-18
 

Hi zulusek please help me
i am using this code to show product on home page

this is my code please take a look if i am use count($_main_categories) then not showing any fatel error but problem is that they not show the records can you help me

$_main_categories=$this->getStoreCategories();

if($_main_categories->count()):

foreach ($_main_categories as $_main_category):
if($_main_category->getIsActive()):

echo $_sub_categories=$_main_category->getChildren();

/*echo the sub_categroires id but not fetching the record in the foreach loop*/

foreach ($_sub_categories as $_sub_category):
if($_sub_category->getIsActive()):
?>
<?php
$cur_category=Mage::getModel('catalog/category')->load($_sub_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category); ?>

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top