user1142052
user1142052

Reputation: 13

Magento Fatal error: Call to a member function getSize()

I have three products assigned to a category below the default category. Manage Categories shows the Category is active and the Category Products tab shows the three products correctly. The category is shown as ID:4

In CMS > Pages > Home Page > Content I have:

{{block type="catalog/product_list" column_count="4" category_id="4" template="catalog/product/list.phtml"}}

After clearing cache and reindexing (many times now) the home page gives me this error:

Fatal error: Call to a member function getSize() on a non-object in /home8/mauipine/public_html/magento/app/design/frontend/default/pineapple/template/catalog/product/list/toolbar_top.phtml on line 34

I have tried many solutions found here and on the Magento site but have been unable to resolve the error. If I use non-existent category_id, e.g. 3 I do not get an error but simply get "There are no products matching the selection."

Upvotes: 0

Views: 5886

Answers (2)

marphy
marphy

Reputation: 11

Great thanks! I had the same problem with 7 In One Catalog By etatvasoft extension and mobileshoppe theme. It is enough to change first condition in toolbar_top and toolbar_bottom template this way:

<?php if(is_object($this->getCollection()) and $this->getCollection()->getSize()): ?>

Upvotes: 1

Alana Storm
Alana Storm

Reputation: 166046

It's going to be difficult for someone to give you a concrete answer on this. As Per your error

Fatal error: Call to a member function getSize() on a non-object in /home8/mauipine/public_html/magento/app/design/frontend/default/pineapple/template/catalog/product/list/toolbar_top.phtml on line 34

The toolbar_top.phtml file is not (to my knowledge) part of any standard Magento installation. Your custom pineapple theme added this file, and somehow incorporated it into your Magento system's layout. Unfortunately, it appears to be incompatible with the catalog/product_list block call you're making. Somewhere in that file you'll see a call to getSize, something like this (the variable probably won't be named $object)

$object->getSize();

The brute force fix would be to add conditional code around that statement otherwise account for the face $object might not be instantiated.

if(is_object($object))
{
    $object->getSize();
}

Upvotes: 1

Related Questions