1

Have problem with my custom module to show custom items to totals. When place order the error show up:

The address total model should be extended from Mage_Sales_Model_Quote_Address_Total_Abstract.

I already try clear magento cache from dashboard, empty var/cache folder, reindexing from dashboad, run compilation proccess, check folder and files permissions and last try reinstall Magento with fresh core files. Also try extension on different install of Magento. And nothing helps.

This is my Quote Adress model:

<?php

 class Devpassion_Rowtotal_Model_Quote_Address_Total_Totalpopust extends       Mage_Sales_Model_Quote_Address_Total_Abstract {


public function collect(Mage_Sales_Model_Quote_Address $address)
{
    parent::collect($address); 

    $order = $address->getOrder();
    $items = $address->getAllItems();

    $subtotaldisc = 0;
    foreach ($items as $item){
            $subtotaldisc += $item->getRowTotal() + $item->getTaxAmount() + $item->getHiddenTaxAmount() - $item->getDiscountAmount();  
        }

    $result = 10 ;

    // Store it to address, used for fetch method
    $address->setRowtotalResult($result);


    return $this;

}

public function fetch(Mage_Sales_Model_Quote_Address $address)
{

        // got $result before using it
        $result = $address->getRowtotalResult();
   // End

        if ($result != 0) {
            $address->addTotal(array(
                'code'  => $this->getCode(),
                'title' => 'Cijena sa popustom',
                'value' => $result
            ));
        }


    return $this;
}


}

?>

And this is my Block class:

<?php

 class Devpassion_Rowtotal_Block_Sales_Total_Totalpopust
   extends Mage_Core_Block_Abstract
 {
     public function initTotals()
{

   $parent = $this->getParentBlock();

   $value = $parent->getSource()->getRowtotalResult();    

   $test = 10 ;

   if ($value > 0)
    {
        $this->getParentBlock()->addTotal(new Varien_Object(array(
        'code'  => 'rowtotal',
        'value' =>  $value,
        'label' => 'Cijena sa popustom blabla',
        'field' => 'totalpopust'
        )),'subtotal');
    } 



}


 }

?>

And my config.xml

<?xml version="1.0"?>
 <config>
 <modules>
    <Devpassion_Rowtotal>
        <version>0.0.1</version>
    </Devpassion_Rowtotal>
</modules>
 <frontend>
    <routers>
        <rowtotal>
            <use>standard</use>
            <args>
                <module>Devpassion_Rowtotal</module>
                <frontName>rowtotal</frontName>
            </args>
        </rowtotal>
    </routers>
    <layout>
        <updates>
            <rowtotal>
                <file>rowtotal.xml</file>
            </rowtotal>
        </updates>
    </layout>
 </frontend>
 <global>
    <sales>
        <quote>
            <totals>
                <rowtotal>
                        <class>rowtotal/quote_address_total_totalpopust</class>
                    <before></before><!-- calculate before these total models -->
                    <after></after><!-- calculate after these total models -->
                </rowtotal>
            </totals>
        </quote>
        <order_invoice>
            <totals>
                <rowtotal>
                    <class>rowtotal/order_invoice_total_totalpopust</class>
                    <after>subtotal</after>
                    <before>shipping</before>
                </rowtotal>
            </totals>
        </order_invoice>
        <order_creditmemo>
            <totals>
                <rowtotal>
                    <class>rowtotal/order_creditmemo_total_totalpopust</class>
                    <after>subtotal</after>
                    <before>shipping</before>
                </rowtotal>
            </totals>
        </order_creditmemo>
    </sales>

    <blocks>
        <rowtotal>
            <class>Devpassion_Rowtotal_Block</class>    
        </rowtotal>
    </blocks>

    <pdf>
        <totals>
          <totalpdf translate="title">
            <title>Ukupno s popustom</title>
            <source_field>totalpdf</source_field>
            <model>rowtotal/pdf_totalpdf</model>
            <font_size>7</font_size>
            <display_zero>0</display_zero>
            <sort_order>450</sort_order>
          </totalpdf>
        </totals>
    </pdf>

    <fieldsets>
        <sales_convert_quote_address>
            <rowtotal_amount><to_order>*</to_order></rowtotal_amount>
        </sales_convert_quote_address>
    </fieldsets>

</global>

  • I got same error when I used wrong class name Namespace_Modulename_Quote_Address_Total_Myclass instead of Namespace_Modulename_Model_Quote_Address_Total_Myclass – Mukesh Sep 11 '19 at 12:54
1

As you can see, you extend your Model from the required class.

There are three options:

  1. You made something wrong
  2. Magento checks something different and outputs a wrong error message
  3. This is not the source of the error

Case 1: Obviously you extended the correct class - I think you made everything correct.

Case 2: Let's see where this error is thrown. I find only one occurrence of the error message, here:

//app/code/core/Mage/Sales/Model/Quote/Address/Total/Collector.php:117
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.')
    );
}

So magento checks, what it should check.

I think it is case 3: You don't have the source of the error. Turn on xdebug (or var_dump()) and check what $model is, when this error occurs.

| improve this answer | |
  • thanks Fabian for advices I resloved error. Now I can see row with label and correct value on cart overview and also on checkout, which is read it from my Qoute address class. But value on Customers order view is still zero. So obviously is something wrong with my Block class? Btw. I can see row with label on order view, which is read it from that Block class. – srdan Aug 18 '13 at 14:37
  • I'm not in it and don't have the time at the moment to dig into it. No idea, sorry. – Fabian Blechschmidt Aug 19 '13 at 7:34
0

I had the exact same problem.

Thanks to @fabian and his great answer, i dumped the content of $model and saw that it was [module]_Sales_Model_Quote_Address_Total_Nominal which had no sense at all since i was overriding the [module]_Sales_Model_Quote_Address_Total_Shipping.

Then i saw my mistake : the file i created was shipping.php instead of Shipping.php with a capital S.

Hope that'll help :).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.