I am getting this weird one When an shipping is created then navigating to Shippings enter image description here

I the Action column when click view I get the error:

1 exception(s): Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in ../../../../htdocs/vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/packed.phtml on line 12

I looked at the packed.html and this is the line

<?php foreach ($block->getPackages() as $packageId => $package): ?>

I debug by:

print_r(gettype($block->getPackages())); RETURNS string 
print_r($block->getPackages()); RETURNS []

I am really confused I got dev environment which works fine and they return:

print_r(gettype($block->getPackages())); RETURNS array 
print_r($block->getPackages()); RETURNS Array()

There is definitely a difference there but what caused this not sure

Looking at teh:

public function getPackages()
   return $this->getShipment()->getPackages();

PhpStorn inspection definitely complaint about return string when should return array Anyone have any idea is this a bug?


This may not be the complete answer to the problem but it fix the shipping order page by the suppressing Warning e.g error_reporting(E_ERROR | E_PARSE); at the packed.phtml But still doesn't make sense and I think it's a bug and hasn't been tested enough and if you have a solution please post your answer I would like to hear. thanks

| improve this answer | |
  • Thank you. This worked on my setup Magento 2.2.5. Not sure what is the invalid argument though. – Mohammed Joraid Jun 17 '19 at 8:40

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.