Skip to content

Commit 4d8ec28

Browse files
committed
ENG26-51 Fix error in syncronizer around incrementing boolean
1 parent 4636b2a commit 4d8ec28

File tree

7 files changed

+73
-8
lines changed

7 files changed

+73
-8
lines changed

CHANGELOG-PUBLIC.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,3 +860,7 @@ SHQ23-6150 Cast method titles to string instead of Phrase
860860
INFRA-1328 - Removed incorrect case-sensitive version of file
861861

862862

863+
## 20.61.2 (2026-01-13)
864+
ENG26-51 Fix error in syncronizer around incrementing boolean
865+
866+

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,3 +860,7 @@ SHQ23-6150 Cast method titles to string instead of Phrase
860860
INFRA-1328 - Removed incorrect case-sensitive version of file
861861

862862

863+
## 20.61.2 (2026-01-13)
864+
ENG26-51 Fix error in syncronizer around incrementing boolean
865+
866+

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shipperhq/module-shipper",
33
"description": "Magento Shipping integration with ShipperHQ",
44
"type": "magento2-module",
5-
"version": "20.61.1",
5+
"version": "20.61.2",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

src/Model/Synchronizer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ public function synchronizeData()
619619
private function updateAll($updateData)
620620
{
621621
$result = 0;
622+
$hasError = false;
622623

623624
foreach ($updateData as $attributeUpdate) {
624625
if ($attributeUpdate['attribute_type'] == 'product') {
@@ -636,7 +637,7 @@ private function updateAll($updateData)
636637
'Unable to add attribute option',
637638
'Error: ' . $e->getMessage()
638639
);
639-
$result = false;
640+
$hasError = true;
640641
}
641642
} elseif ($attributeUpdate['status'] == self::AUTO_REMOVE_ATTRIBUTE_OPTION) {
642643
try {
@@ -651,7 +652,7 @@ private function updateAll($updateData)
651652
'Unable to remove attribute option',
652653
'Error: ' . $e->getMessage()
653654
);
654-
$result = false;
655+
$hasError = true;
655656
}
656657
}
657658
} elseif ($attributeUpdate['attribute_type'] == 'global_setting') {
@@ -710,7 +711,7 @@ private function updateAll($updateData)
710711

711712
$this->carrierConfigHandler->refreshConfig();
712713

713-
if ($result >= 0) {
714+
if (!$hasError && $result >= 0) {
714715
$this->checkSynchStatus(true);
715716
}
716717
return $result;

src/Plugin/Quote/QuoteManagementPlugin.php

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Magento\Quote\Model\QuoteManagement;
3838
use ShipperHQ\Shipper\Helper\CarrierGroup;
3939
use ShipperHQ\Shipper\Helper\LogAssist;
40+
use ShipperHQ\Shipper\Model\ResourceModel\Quote\AddressDetail\CollectionFactory as AddressDetailCollectionFactory;
4041

4142
class QuoteManagementPlugin
4243
{
@@ -65,18 +66,25 @@ class QuoteManagementPlugin
6566
*/
6667
private $logger;
6768

69+
/**
70+
* @var AddressDetailCollectionFactory
71+
*/
72+
private $addressDetailCollectionFactory;
73+
6874
public function __construct(
6975
CartRepositoryInterface $quoteRepository,
7076
ManagerInterface $eventManager,
7177
DataObjectFactory $objectFactory,
7278
CarrierGroup $carrierGroupHelper,
73-
LogAssist $logger
79+
LogAssist $logger,
80+
AddressDetailCollectionFactory $addressDetailCollectionFactory
7481
) {
7582
$this->quoteRepository = $quoteRepository;
7683
$this->eventManager = $eventManager;
7784
$this->objectFactory = $objectFactory;
7885
$this->carrierGroupHelper = $carrierGroupHelper;
7986
$this->logger = $logger;
87+
$this->addressDetailCollectionFactory = $addressDetailCollectionFactory;
8088
}
8189

8290
/**
@@ -115,11 +123,17 @@ private function updateCarrierGroupDetails(int $cartId): void
115123
if (!$address) {
116124
return;
117125
}
126+
118127
$shippingMethod = (string) $address->getShippingMethod();
119128
if (!$shippingMethod) {
120129
return;
121130
}
122131

132+
// Extension attributes have been wiped by this point as they're just held in memory and Magento
133+
// has reloaded the quote address from the DB now. Let's get them from shipperhq_quote_address_detail
134+
// which has been updated at this point to have the correct values
135+
$addressExtensionAttributes = $this->getQuoteAddressDetails($address->getId());
136+
123137
$additionalDetail = $this->objectFactory->create();
124138
$carrierCode = '';
125139
if (strpos($shippingMethod, '_') !== false) {
@@ -130,7 +144,7 @@ private function updateCarrierGroupDetails(int $cartId): void
130144
$this->eventManager->dispatch(
131145
'shipperhq_additional_detail_checkout',
132146
[
133-
'address_extn_attributes' => $address->getExtensionAttributes(),
147+
'address_extn_attributes' => $addressExtensionAttributes,
134148
'additional_detail' => $additionalDetail,
135149
'carrier_code' => $carrierCode,
136150
'address' => $address,
@@ -143,6 +157,8 @@ private function updateCarrierGroupDetails(int $cartId): void
143157
$shippingMethod,
144158
$additionalDetail->convertToArray()
145159
);
160+
161+
146162
} catch (\Throwable $e) {
147163
$this->logger->postCritical(
148164
'Shipperhq_Shipper',
@@ -151,4 +167,44 @@ private function updateCarrierGroupDetails(int $cartId): void
151167
);
152168
}
153169
}
170+
171+
/**
172+
* Get quote address details for a given address ID and extract what would have been extension attributes
173+
*
174+
* @param int $addressId
175+
* @return \Magento\Framework\DataObject
176+
*/
177+
private function getQuoteAddressDetails(int $addressId)
178+
{
179+
$collection = $this->addressDetailCollectionFactory->create()
180+
->addAddressToFilter($addressId);
181+
182+
$extensionAttributes = $this->objectFactory->create();
183+
184+
foreach ($collection as $detail) {
185+
if ($detail->getDeliveryDate()) {
186+
$extensionAttributes->setDeliveryDate($detail->getDeliveryDate());
187+
188+
if ($detail->getTimeSlot()) {
189+
$extensionAttributes->setTimeSlot($detail->getTimeSlot());
190+
}
191+
}
192+
193+
if ($detail->getPickupLocationId()) {
194+
$extensionAttributes->setLocationId($detail->getPickupLocationId());
195+
}
196+
197+
if ($detail->getPickupLocation()) {
198+
$extensionAttributes->setLocationAddress($detail->getPickupLocation());
199+
}
200+
201+
$this->logger->postDebug(
202+
'Shipperhq_Shipper',
203+
'Extension Attributes Extracted from Address Detail',
204+
$extensionAttributes->getData()
205+
);
206+
}
207+
208+
return $extensionAttributes;
209+
}
154210
}

src/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shipperhq/module-shipper",
33
"description": "Magento Shipping integration with ShipperHQ",
44
"type": "magento2-module",
5-
"version": "20.61.1",
5+
"version": "20.61.2",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

src/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<ws_timeout>30</ws_timeout>
7373
<use_cache>0</use_cache>
7474
<always_use_cache>1</always_use_cache>
75-
<extension_version>20.61.1</extension_version>
75+
<extension_version>20.61.2</extension_version>
7676
<allowed_methods></allowed_methods>
7777
<magento_version></magento_version>
7878
<cache_timeout>300</cache_timeout>

0 commit comments

Comments
 (0)