Skip to content

Commit

Permalink
Merge pull request #33 from sequra/fix/CS-6051
Browse files Browse the repository at this point in the history
Fix the issue with wrong URL for live environment
  • Loading branch information
m1k3lm authored Oct 16, 2024
2 parents 3f371a0 + 2011907 commit ed781be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 60 deletions.
25 changes: 5 additions & 20 deletions Observer/OrderAddressObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class OrderAddressObserver implements ObserverInterface
*/
private $transformService;

/**
* @var OrderService
*/
private $orderService;

/**
* @param SeQuraTranslationProvider $translationProvider
* @param TransformEntityService $transformService
Expand Down Expand Up @@ -94,7 +89,11 @@ private function handleAddressUpdate(MagentoAddress $magentoAddress): void
$isShippingAddress = $magentoAddress->getAddressType() === 'shipping';
$address = $this->transformService->transformAddressToSeQuraOrderAddress($magentoAddress);

StoreContext::doWithStore($magentoOrder->getStoreId(), [$this->getOrderService(), 'updateOrder'], [
$orderService = StoreContext::doWithStore($magentoOrder->getStoreId(), function () {
return ServiceRegister::getService(OrderService::class);
});

StoreContext::doWithStore($magentoOrder->getStoreId(), [$orderService, 'updateOrder'], [
new OrderUpdateData(
$magentoOrder->getIncrementId(), null, null,
$isShippingAddress ? $address : null,
Expand All @@ -103,20 +102,6 @@ private function handleAddressUpdate(MagentoAddress $magentoAddress): void
]);
}

/**
* Returns an instance of Order service.
*
* @return OrderService
*/
private function getOrderService(): OrderService
{
if (!isset($this->orderService)) {
$this->orderService = ServiceRegister::getService(OrderService::class);
}

return $this->orderService;
}

/**
* Handles the update address errors.
*
Expand Down
25 changes: 5 additions & 20 deletions Observer/OrderCancellationObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class OrderCancellationObserver implements ObserverInterface
*/
private $translationProvider;

/**
* @var OrderService
*/
private $orderService;

/**
* @param SeQuraTranslationProvider $translationProvider
*/
Expand Down Expand Up @@ -79,7 +74,11 @@ private function handleCancellation(MagentoOrder $orderData): void
throw new LocalizedException($this->translationProvider->translate('sequra.error.cannotCancel'));
}

StoreContext::doWithStore($orderData->getStoreId(), [$this->getOrderService(), 'updateOrder'], [
$orderService = StoreContext::doWithStore($orderData->getStoreId(), function () {
return ServiceRegister::getService(OrderService::class);
});

StoreContext::doWithStore($orderData->getStoreId(), [$orderService, 'updateOrder'], [
new OrderUpdateData(
$orderData->getIncrementId(),
new SeQuraCart($orderData->getOrderCurrencyCode()),
Expand All @@ -89,20 +88,6 @@ private function handleCancellation(MagentoOrder $orderData): void
]);
}

/**
* Returns an instance of Order service.
*
* @return OrderService
*/
private function getOrderService(): OrderService
{
if (!isset($this->orderService)) {
$this->orderService = ServiceRegister::getService(OrderService::class);
}

return $this->orderService;
}

/**
* Handles the order cancellation errors.
*
Expand Down
25 changes: 5 additions & 20 deletions Observer/OrderShipmentObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class OrderShipmentObserver implements ObserverInterface
*/
private $transformService;

/**
* @var OrderService
*/
private $orderService;

/**
* @param SeQuraTranslationProvider $translationProvider
* @param TransformEntityService $transformService
Expand Down Expand Up @@ -89,7 +84,11 @@ private function handleShipment(MagentoShipment $shipmentData): void
$unshippedCart = $this->transformService->transformOrderCartToSeQuraCart($orderData, false);
$shippedCart = $this->transformService->transformOrderCartToSeQuraCart($orderData, true);

StoreContext::doWithStore($orderData->getStoreId(), [$this->getOrderService(), 'updateOrder'], [
$orderService = StoreContext::doWithStore($orderData->getStoreId(), function () {
return ServiceRegister::getService(OrderService::class);
});

StoreContext::doWithStore($orderData->getStoreId(), [$orderService, 'updateOrder'], [
new OrderUpdateData(
$orderData->getIncrementId(),
$shippedCart,
Expand All @@ -100,20 +99,6 @@ private function handleShipment(MagentoShipment $shipmentData): void
]);
}

/**
* Returns an instance of Order service.
*
* @return OrderService
*/
private function getOrderService(): OrderService
{
if (!isset($this->orderService)) {
$this->orderService = ServiceRegister::getService(OrderService::class);
}

return $this->orderService;
}

/**
* Handles the order shipment errors.
*
Expand Down

0 comments on commit ed781be

Please sign in to comment.