简体   繁体   中英

Magento - unable to view order after upgrade to 2.4.3

I've recently upgraded a Magento (open source) store from 2.4.2 to 2.4.3. A customer has placed an order using PayPal Express Checkout as the payment method.

When I try to view their order in the admin screens, I get the error Exception occurred during order load .

If I then check the exception.log, I get the following message:

main.CRITICAL: Type Error occurred when creating object: Magento\InventorySourceSelection\Model\Address, Argument 1 passed to Magento\InventorySourceSelection\Model\Address::__construct() must be of the type string, null given, called in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 {"exception":"[object] (Magento\\Framework\\Exception\\RuntimeException(code: 0): Type Error occurred when creating object: Magento\\InventorySourceSelection\\Model\\Address, Argument 1 passed to Magento\\InventorySourceSelection\\Model\\Address::__construct() must be of the type string, null given, called in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 at vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131)"} []

I assume this is caused by the 2.4.3 upgrade, as other orders prior to that have been OK. Most orders after the upgrade are fine too, so something is odd about this one. I've checked:

  • the product ordered is in stock
  • the billing and shipping addresses are complete (they were missing the county / state, but this isn't required for my store)

It appears to be the same issue noted here on GitHub .

I've also tried on my test box to upgrade to 2.4.3-p1 to see if that helps, but to no avail. I've tried the normal tricks of DI compile, cache clear, re-indexing etc.

Has anyone experienced this before and have any tips how to debug it? I'm unable to process the order at present.

From the error message, I guess that this problem occurs because the customer's address in this order is wrong or missing data.

Please double-check the address and make sure you have all the information and especially the postcode.

In case of missing data you just need to update the address and everything will work.

It turns out it is a bug in the Amasty Shipping Table Rates module (found via https://github.com/magento/inventory/issues/2362 ).

The fix is to change:

return $this->inventorySourceSelectionAddressFactory->create([
            'country'   => $shippingAddress->getCountryId(),
            'postcode'  => $shippingAddress->getPostcode() ?? '',
            'street'    => implode("\n", $shippingAddress->getStreet()),
            'region'    => $shippingAddress->getRegionCode() ?? '',
            'city'      => $shippingAddress->getCity() ?? ''
        ]);

to....

return $this->inventorySourceSelectionAddressFactory->create([
            'country'   => $shippingAddress->getCountryId() ?? '',
            'postcode'  => $shippingAddress->getPostcode() ?? '',
            'street'    => implode("\n", $shippingAddress->getStreet()),
            'region'    => $shippingAddress->getRegionCode() ?? '',
            'city'      => $shippingAddress->getCity() ?? ''
        ]);

(the change is on getCountryId())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM