tradefurniturecompany / site

tradefurniturecompany.co.uk (Magento 2)
https://upwork.com/fl/mage2pro
2 stars 0 forks source link

[`Mageplaza_Osc`] «Object of class Magento\Customer\Model\Data\Region could not be converted to string in vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:3102» #260

Closed dmitrii-fediuk closed 1 year ago

dmitrii-fediuk commented 1 year ago

https://github.com/magento/magento2/issues/4187, https://github.com/magento/magento2/issues/7387, https://github.com/magento/magento2/issues/12436


We are facing the same error when the customer address has not region.

https://github.com/magento/magento2/issues/4187#issuecomment-255110528


This needs re-opening and resolving. At the moment you only support countries with regions. Its pretty clear bug and affecting all UK magento 2 installs.

github.com/magento/magento2/issues/4187#issuecomment-259368636

dmitrii-fediuk commented 1 year ago

How to reproduce

https://github.com/magento/magento2/issues/7387#issuecomment-260896083

I realise the checkout works without my test extension - because the core code statement causing the bug is not executed during this flow. There is a bug in your code when you save a UK address without a region ($address->save()).

https://github.com/magento/magento2/issues/7387#issuecomment-262126410

dmitrii-fediuk commented 1 year ago

A workaround

https://github.com/magento/magento2/issues/7387#issuecomment-263586330

dmitrii-fediuk commented 1 year ago

I have reproduced it on the /checkout/cart/ page:

mage2pro/core: 9.8.3
Magento: 2.3.7-p4
PHP: 7.4.9
IP Address: 158.181.235.66
Referer: https://localhost.com:2197/checkout/cart/
Request Method: POST
URL: https://localhost.com:2197/rest/default/V1/carts/mine/estimate-shipping-methods-by-address-id
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
php://input: {"addressId":"53124"}
File: vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
Line: 3102
************************************
[E_ERROR] Uncaught Error: Object of class Magento\Customer\Model\Data\Region could not be converted to string in vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:3102
Stack trace:
#0 generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php(817): Magento\Framework\DB\Adapter\Pdo\Mysql->prepareColumnValue(Array, Object(Magento\Customer\Model\Data\Region))
#1 vendor/magento/framework/Model/ResourceModel/AbstractResource.php(184): Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->prepareColumnValue(Array, Object(Magento\Customer\Model\Data\Region))
#2 vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(750): Magento\Framework\Model\ResourceModel\AbstractResource->_prepareDataForTable(Object(Magento\Quote\Model\Quote\Address\Interceptor), 'quote_address')
dmitrii-fediuk commented 1 year ago
mage2pro/core: 10.0.7
Magento: 2.3.7-p4
PHP: 7.4.9
IP Address: 158.181.235.66
Referer: https://localhost.com:2197/checkout/cart/
Request Method: POST
URL: https://localhost.com:2197/rest/default/V1/carts/mine/estimate-shipping-methods-by-address-id
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
php://input: {"addressId":"53124"}
File: vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
Line: 3102
************************************
[E_ERROR] Uncaught Error: Object of class Magento\Customer\Model\Data\Region could not be converted to string in vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:3102
Stack trace:
#0 generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php(817): Magento\Framework\DB\Adapter\Pdo\Mysql->prepareColumnValue(Array, Object(Magento\Customer\Model\Data\Region))
#1 vendor/magento/framework/Model/ResourceModel/AbstractResource.php(184): Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->prepareColumnValue(Array, Object(Magento\Customer\Model\Data\Region))
#2 vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(750): Magento\Framework\Model\ResourceModel\AbstractResource->_prepareDataForTable(Object(Magento\Quote\Model\Quote\Address\Interceptor), 'quote_address')
dmitrii-fediuk commented 1 year ago

How do I reproduce it on the /checkout/cart page

Step 1

DELETE FROM quote_shipping_rate

E.g.:

mysql -D tradefurniturecompany_co_uk_2020_11_09 -e "DELETE FROM quote_shipping_rate";

Step 2

rm -rf var/cache var/log var/page_cache var/view_preprocessed

Step 3

Delete the Local Storage content from the browser.

Step 4

Reload the page in the browser.