cancel
Showing results for 
Search instead for 
Did you mean: 

After upgrading to 1.9 we encounter an error saying the address total model is extending wrong class

After upgrading to 1.9 we encounter an error saying the address total model is extending wrong class

I just upgraded our Magento instance from v1.7 to v1.9. And one of the stores websites is now receiving an error when the cart gets updated: The address total model should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract.

 

I came across a Stack Overflow post where the OP encountered the same error, but it looks like it was caused by a different problem.

 

I grepped through the PHP files for a string matching the error above, and can see it originates from the file base/app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php. Here's the method containing the logic throwing the error:

 

/**
 * Init model class by configuration
 *
 * @param string $class
 * @param string $totalCode
 * @param array $totalConfig
 * @return Mage_Sales_Model_Quote_Address_Total_Abstract
 */
protected function _initModelInstance($class, $totalCode, $totalConfig)
{
    $model = Mage::getModel($class);
    if (!$model instanceof Mage_Sales_Model_Quote_Address_Total_Abstract) {
        Mage::throwException(
            Mage::helper('sales')->__('The address total model should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract.')
        );
    }

    $model->setCode($totalCode);
    $this->_modelsConfig[$totalCode]= $this->_prepareConfigArray($totalCode, $totalConfig);
    $this->_modelsConfig[$totalCode]= $model->processConfigArray(
        $this->_modelsConfig[$totalCode],
        $this->_store
    );

    return $model;
}

I took the advice posted in the other thread and dumped the content of $model to see what class it was actually an instance off Mage_Sales_Model_Quote_Address_Total_Nominal.

 

So the Mage_Sales_Model_Quote_Address_Total_Collector::_initModelInstance() 
method within base/app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php is requiring the $method to be an instance of Mage_Sales_Model_Quote_Address_Total_Abstract, but it's actually an instance of Mage_Sales_Model_Quote_Address_Total_Nominal.

 

After grepping around for a bit, I can see that the Mage_Sales_Model_Quote_Address_Total_Nominal class is declared within the base/app/code/core/Mage/Sales/Model/Quote/Address/Total/Nominal.php file, and when I open it up, I see that the class Mage_Sales_Model_Quote_Address_Total_Nominal actually extends the abstract class Mage_Sales_Model_Quote_Address_Total_Abstract

 

So instead of:

Mage_Sales_Model_Quote_Address_Total_Abstract -> $method

It's:
Mage_Sales_Model_Quote_Address_Total_Abstract -> Mage_Sales_Model_Quote_Address_Total_Nominal -> $method

 

I'm not quite sure what to make of this. The abstract class is being extended, it's just one "level" further back than it's expected to be.

 

Any input or suggestions would be greatly appreciated.

 

Thanks!

2 REPLIES

Re: After upgrading to 1.9 we encounter an error saying the address total model is extending wrong c

Bump?

Re: After upgrading to 1.9 we encounter an error saying the address total model is extending wrong c

3248494-i-dont-always-bump-threads-but-when-i-do-i-use-memes.jpg