0

This question already has an answer here:

When I click the Add to cart button I'm getting the following error "Fatal error: Call to a member function setStore() on a non-object in ../app/code/core/Mage/Shipping/Model/Shipping.php"

This is the function that throws it:

   public function getCarrierByCode($carrierCode, $storeId = null)
    {
        if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/'.$this->_availabilityConfigField, $storeId)) {
            return false;
        }
        $className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId);
        if (!$className) {
            return false;
        }
        $obj = Mage::getModel($className);
        if ($storeId) {
            $obj->setStore($storeId);
        }
        return $obj;
    }

This code in particular:

$obj = Mage::getModel($className);
if ($storeId) {
    $obj->setStore($storeId);
}

I have printed out the $obj and I'm getting the following object:

Mage_GoogleCheckout_Model_Shipping Object
(
    [_code:protected] => googlecheckout
    [_rates:protected] => 
    [_numBoxes:protected] => 1
    [_freeMethod:protected] => free_method
    [_isFixed:protected] => 
    [_customizableContainerTypes:protected] => Array
        (
        )

    [_debugReplacePrivateDataKeys:protected] => Array
        (
        )

    [_data:protected] => Array
        (
        )

    [_hasDataChanges:protected] => 
    [_origData:protected] => 
    [_idFieldName:protected] => 
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)

This Mage_GoogleCheckout_Model_Shipping class is present, it's in the right location.

I can see that the functions loads the $className in the following manner:

$className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId);

and while for the Fedex, UPS etc. methods I see entries in the core_config_data table like this carriers/fedex/something, for the Google Checkout I do not, but I see the following instead: google/checkout_shipping_carrier/active and many others that do not follow the carriers/carrierCode pattern.

Anyway, does someone know why this is happening? Thanks

marked as duplicate by David Manners, Matthias Zeis, Marius, Anna Völkl, Vladimir Kerkhoff Nov 20 '14 at 9:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

You can probably safely disable Mage_GoogleCheckout in System -> Config -> Advanced -> Advanced because per this post, Google Checkout officially stopped in November 2013 and Magento dropped support for it:

Magento 1.8.1.0 Google Checkout missing - comparing to 1.8.0.0

  • Ok, I've disabled Mage_GoogleCheckout and the error in Sales -> Google API is gone, but the error on the frontend when adding to cart is still there. Do you think it's wise to remove the DB entries for GoogleCheckout? – user12102 Sep 16 '14 at 14:43
  • Removing the database entries would probably just lead to a different error. Try renaming the layout file googlecheckout.xml to remove it for your theme and see if that fixes your front-end error. – Don Sep 16 '14 at 14:55
  • Did not help at all – user12102 Sep 16 '14 at 15:01
0

Google checkout no longer exists but should you need the module working for some reason my guess is that the contents of $className is not valid so getModel() is not returning an object.

  • Ok, I've disabled Mage_GoogleCheckout and the error in Sales -> Google API is gone, but the error on the frontend when adding to cart is still there. Do you think it's wise to remove the DB entries for GoogleCheckout? – user12102 Sep 16 '14 at 14:43
  • How have you disabled Mage_GoogleCheckout? – Jonathan Hussey Sep 16 '14 at 14:54
  • By setting this <Mage_GoogleCheckout> <active>false</active> in Mage_All.xml – user12102 Sep 16 '14 at 14:58
  • Cleared at least the config cache? – Jonathan Hussey Sep 16 '14 at 15:07
  • Yeah, I've emptied the var/cache directory manually. No dice :/ – user12102 Sep 17 '14 at 8:16