Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Call to member function getSku() on a non-object FATAL ERROR! 
 
Jeremiah
Member
 
Avatar
Total Posts:  31
Joined:  2008-01-10
 

I have come across a bizarre error in Magento shop and despite my inquiries online, it appears no one else has ever seen this exact error.

The full text of the error message is this:

Fatal error: Cal to a member function getSku() on a non-object in /path/on/server/app/code/core/Mage/Catalog/Model/Product/Option/Type/Select.php on line 221.

Now, others have gotten this error message--it was addressed and supposedly fixed in the 1.3.1 roadmap (http://www.magentocommerce.com/roadmap/release/1.3.1). However, the circumstances of those other error messages were where they tried to add an item to the cart--if the item had custom options, it would loop to this error message.

My situation is that I have a SIMPLE item--not bundled or configurable--without any custom options. I can add it to the cart without any trouble. But if I run through the entire checkout procedure, upon placing the order, the error message appears on a white screen. The URL in the browser shows me I’m on the checkout success page.

AND, the order appears to go through perfectly, getting registered by both Magento AND Authorize.net.

I’ve tried debugging the error as far as I can go, but this one’s got me stumped.

For reference, I’m in Magento 1.3.2.4. When I first received the error I reinstalled all the core files and was still able to replicate the error.

I’m going to continue to test, but if anyone has ANY bright ideas about why this is happening, I’d love to hear your thoughts. I’m so close to launch and this thing could put the kibosh on the whole thing.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jeremiah
Member
 
Avatar
Total Posts:  31
Joined:  2008-01-10
 

Bump. I’ve tried debugging the file in question with Firebug. Unfortunately, it isn’t a javascript issue, so I can’t parse what’s happening behind the scenes with the PHP.

Next step is to backup the db, do a completely fresh install, and see if that works.

 
Magento Community Magento Community
Magento Community
Magento Community
 
macateem
Jr. Member
 
Total Posts:  16
Joined:  2009-02-17
 

My client is on 1.3.2.3 and they use a McAfee service that tests the site for vulnerabilities.  One of the scans found this error as well.  Anyone find a solution for this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
wattzy
Jr. Member
 
Total Posts:  15
Joined:  2010-11-15
 

I’m also having this problem except

Fatal error: Call to a member function getSku() on a non-object in app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php on line 710

comes up after trying to login to the store.

If I refresh the page, the error disappears and then the user is logged in as per usual.

 Signature 

Get Magento Database Config Details

 
Magento Community Magento Community
Magento Community
Magento Community
 
wattzy
Jr. Member
 
Total Posts:  15
Joined:  2010-11-15
 

I’ve looked at the code and found the error which is located in this method

app/code/core/Mage/Catalog/Model/Product/Type/Configurable - lines 706 to 718

public function getSku($product = null)
{
$sku = $this->getProduct($product)->getData(’sku’);
if ($simpleOption = $this->getProduct($product)->getCustomOption(’simple_product’)) {
$simple_sku = $simpleOption->getProduct($product)->getSku();
$sku = parent::getOptionSku($product, $simple_sku);
} else {
$sku = parent::getSku($product);
}

return $sku;
}

The actual error is coming from the line.

$simple_sku = $simpleOption->getProduct($product)->getSku();

If I comment that line out the login page works again, but I’m not sure if that line is important?

 Signature 

Get Magento Database Config Details

 
Magento Community Magento Community
Magento Community
Magento Community
 
adamwknox
Jr. Member
 
Total Posts:  4
Joined:  2011-01-25
 

bump

Hit this when i tried creating a configurable product with the “quick simple product creation”.

also I just upgraded from 1.3 to 1.4

 
Magento Community Magento Community
Magento Community
Magento Community
 
quicksand14
Member
 
Total Posts:  55
Joined:  2010-09-30
 

watzy - i’m having the same issue - right after login. its odd and fresh, since we have 20+ configurable products created, I can’t figure out what’s caused it

any solution?

 
Magento Community Magento Community
Magento Community
Magento Community
 
archmad
Member
 
Avatar
Total Posts:  31
Joined:  2010-04-03
Philippines
 

I too had the same problem but just fixed it. My account has a pending items on my cart, when I logged in, i get this error. Im not too sure but when I checked the product list in admin, those items in my cart does not exist anymore. I must have deleted it in the back end and could have caused the error. So if this is the case, this should be a bug or something.

Solution:

Go to app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php

Edit line 710

from

$simple_sku $simpleOption->getProduct($product)->getSku();
to
$o$simpleOption->getProduct($product);
$simple_sku is_object($o) ? $o->getSku() : null;

 Signature 

Archie Jereos - Difficult is not impossible | If you need Magento websites, work with us at Greater than Website.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tbradley22
Member
 
Total Posts:  44
Joined:  2011-01-27
 

archmad, thank you!!

i had the exact same problem and tried out your solution. it worked perfectly. i don’t know php so i definitely would have been up a river without your solution.

i created a local file so as to no disrupt the core files

/public_html/app/code/local/Mage/Catalog/Model/Product/Type/Configurable.php

ted

 
Magento Community Magento Community
Magento Community
Magento Community
 
KingJackaL
Jr. Member
 
Total Posts:  7
Joined:  2009-09-30
ChCh, NZ
 

We had the same issue in Magento 1.5 - archmad‘s solution would work. However, I’ve back-ported the official fix - Magento have now fixed this (as of Magento 1.6.1.0). The 1.6.1 code (with a variable rename so it can be pasted into 1.5) looks like so:

$optionProduct $simpleOption->getProduct($product);
            
$simple_sku null;
            if (
$optionProduct{
                $simple_sku 
=  $simpleOption->getProduct($product)->getSku();
            
}

...which yeah, does the same thing smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2012 Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
701238 users|881 users currently online|497293 forum posts