From 41c07b77fe016986480abc72225ab2c2ecb356e0 Mon Sep 17 00:00:00 2001 From: ShopWhizzy Date: Fri, 6 Dec 2024 15:46:55 +0000 Subject: [PATCH] Fix Region code String instead of passing object [2024-12-06T15:40:02.775548+00:00] main.CRITICAL: Error: Object of class Magento\Directory\Model\Region could not be converted to string in /home/u15e64ec4506f3/public_html/vendor/magento/module-directory/Model/ResourceModel/Region.php:143 Stack trace: #0 ./vendor/magento/module-directory/Model/Region.php(59): Magento\Directory\Model\ResourceModel\Region->loadByCode() #1 ./vendor/affirm/magento2/Model/Observer/AddressFormat.php(48): Magento\Directory\Model\Region->loadByCode() ... --- Model/Observer/AddressFormat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Observer/AddressFormat.php b/Model/Observer/AddressFormat.php index 0a47171..edd6c79 100644 --- a/Model/Observer/AddressFormat.php +++ b/Model/Observer/AddressFormat.php @@ -45,7 +45,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $regionId = $address->getRegionId(); /** @var \Magento\Directory\Model\Region $region */ $region = $this->regionFactory->create(); - $region->loadByCode($region, $regionId); + $region->loadByCode($address->getRegion(), $regionId); $address->setRegion($region->getName()); $address->setRegionCode($region->getCode()); $address->save();