0

I import all my orders from Magento 1.9 to Magento 2.2, the orders are in the store but when I press on View button, I have the following error:

1 exception(s):
Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /home/magento/vendor/magento/module-weee/Helper/Data.php on line 533

Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /home/magento/vendor/magento/module-weee/Helper/Data.php on line 533
#0 /home/magento/vendor/magento/module-weee/Helper/Data.php(533): Magento\Framework\App\ErrorHandler->handler(2, 'Invalid argumen...', '/home/magento/...', 533, Array)
#1 /home/magento/vendor/magento/module-weee/Block/Item/Price/Renderer.php(448): Magento\Weee\Helper\Data->getBaseRowWeeeTaxInclTax(Object(Magento\Sales\Model\Order\Item\Interceptor))
#2 /home/magento/vendor/magento/module-weee/Block/Adminhtml/Items/Price/Renderer.php(185): Magento\Weee\Block\Item\Price\Renderer->getBaseTotalAmount(Object(Magento\Sales\Model\Order\Item\Interceptor))
#3 /home/magento/vendor/magento/module-weee/view/adminhtml/templates/items/price/total.phtml(16): Magento\Weee\Block\Adminhtml\Items\Price\Renderer->getBaseTotalAmount(Object(Magento\Sales\Model\Order\Item\Interceptor))

What does this mean? Is there any way to fix this?

I add here the entire error:

https://paste.ofcode.org/ZU3EJ5GrGkfQ28L4z3fkKT

EDIT:

At line 533 in the file vendor/magento/module-weee/Helper/Data.php on line 533, I have the following code, I try to add a var_dump but is not work.

foreach ($weeeTaxAppliedAmounts as $weeeTaxAppliedAmount => $test) {
    var_dump($test);
    $totalWeeeTaxIncTaxApplied += max($weeeTaxAppliedAmount['base_row_amount_incl_tax'], 0);
}

Thank you

1

My guess would be some custom fields coming over from Magento 1 but doesn't have a default value when you create the columns in Magento 2.2

However the best way to tackle your problem would be to use xdebug and put a breakpoint in /module-weee/Helper/Data.php

If not possbile you can just add var_dump before the error line and check what's the value passing in the foreach loop.

1
  • Hi thank you for your answer, I can't add xdebug there and I try to add a var_dump there but is not work. I edit my answer and I add what code is there and how I add var_dump, can you take a look please? thanks
    – Robert
    Feb 17 '18 at 10:18
0

I had the same issue.

Not sure why it appears, but if you add some conditions in getRowWeeeTaxInclTax() and getRowWeeeTaxInclTax() in /vendor/magento/module-weee/Helper/Data.php

Is it a bug or somthing we have to check in database?

public function getRowWeeeTaxInclTax($item)
{
    $weeeTaxAppliedAmounts = $this->getApplied($item);
    $totalWeeeTaxIncTaxApplied = 0;
    /* just added */
    if(is_array($weeeTaxAppliedAmounts)){
    foreach ($weeeTaxAppliedAmounts as $weeeTaxAppliedAmount) {
        $totalWeeeTaxIncTaxApplied += max($weeeTaxAppliedAmount['row_amount_incl_tax'], 0);
    }
    }
    return $totalWeeeTaxIncTaxApplied;
}

/**
 * Get the total base weee including tax by row
 *
 * @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
 * @return float
 */
public function getRowWeeeTaxInclTax($item)
{
    $weeeTaxAppliedAmounts = $this->getApplied($item);
    $totalWeeeTaxIncTaxApplied = 0;
    /* just added */ 
    if(is_array($weeeTaxAppliedAmounts)){
      foreach ($weeeTaxAppliedAmounts as $weeeTaxAppliedAmount) {
          $totalWeeeTaxIncTaxApplied += max($weeeTaxAppliedAmount['base_row_amount_incl_tax'], 0);
      }
    }
    return $totalWeeeTaxIncTaxApplied;
}
3
  • It may be related to gielberkers.com/…
    – Kennedy
    Apr 15 '18 at 16:46
  • this was related to migrated data
    – Kennedy
    Nov 8 '18 at 19:10
  • where is the first getBaseRowWeeeTaxInclTax()? Apr 16 '20 at 12:27

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.