2

I m stuck with

Fatal error: Maximum function nesting level of '400'reached

in magento version 1.8.0.0. When i recalculate total in sales_quote_collect_totals_after event.The code of observer is as below

public function recalculateTotal($observer){
 $quote=$observer->getEvent()->getQuote();
 $quote->setTotalsCollectedFlag(false);
 $quote->getShippingAddress()->unsetData('cached_items_all');
 $quote->getShippingAddress()->unsetData('cached_items_nominal');
 $quote->getShippingAddress()->unsetData('cached_items_nonnominal');
 $quote->collectTotals();

}

and the same error occur when i submit my custom form.but if i change form method POST to GET it works fine.

I can't understand what's going inside it.Please can somebody get out from it.

1 Answer 1

2

The problem is the following:

  • collectTotals function in app/code/core/Mage/Sales/Model/Quote.php triggers the sales_quote_collect_totals_after event
  • sales_quote_collect_totals_after event triggers your recalculateTotal observer function
  • your recalculateTotal function calls collectTotals
  • and so on, resulting in an infinite loop

My suggestion:

I'm not sure the reason why you wrote this line:

$quote->setTotalsCollectedFlag(false);

But changing it to:

$quote->setTotalsCollectedFlag(true);

Will fix the infinite loop issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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