bal*_*alu 4 magento magento2.4
我们已将 Magento 版本从 2.3.5p2 升级到 2.4.3 P1。之后在下订单时我们遇到了问题。错误:
Object of class Magento\Quote\Api\Data\AddressExtension could not be converted to string in vendor\magento\module-checkout-staging\Plugin\GuestPaymentInformationManagementPlugin.php:106
Run Code Online (Sandbox Code Playgroud)
我们观察到以下扩展属性的问题是代码
<extension_attributes for="Magento\Quote\Api\Data\AddressInterface">
<attribute code="tm_address_id" type="string" />
Run Code Online (Sandbox Code Playgroud)
如何解决该错误?
我今天遇到了同样的问题,问题发生在vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
这里的错误是,在比较送货地址和帐单地址时,扩展属性无法转换为字符串。
就我而言,扩展属性仅添加到帐单地址,并且在送货与帐单地址的比较中并不重要。
这似乎是 Adobe/Magento 团队未涵盖的意外情况。我找不到任何官方补丁来修复此问题,因此我创建了这个补丁,它只是在与运输数据进行比较之前删除了extension_attributes
密钥$billingData
。
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
Run Code Online (Sandbox Code Playgroud)
编辑:
同样的错误也发生在客人身上vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
相同的解决方案,两个补丁均适用:
diff --git a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
index 2728b160..ee8afacd 100644
--- a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
@@ -101,7 +101,7 @@ class GuestPaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddress->getData());
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData,$shippingData);
return empty($difference);
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 7f0de541..c8444df2 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -117,7 +117,7 @@ class PaymentInformationManagementPlugin
$billingData = $this->convertAddressValueToFlatArray($billingAddressData);
$billingKeys = array_flip(array_keys($billingData));
$shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
+ $removeKeys = ['region_code', 'save_in_address_book', 'extension_attributes'];
$billingData = array_diff_key($billingData, array_flip($removeKeys));
$difference = array_diff($billingData, $shippingData);
$sameAsBillingFlag = empty($difference);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2351 次 |
最近记录: |