Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue with wrong URL for live environment #33

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading