From 0c6146e803b857c6a52642940ea27bb9d8f468e6 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Mon, 28 Sep 2020 15:36:52 +0200 Subject: [PATCH 1/7] CHANGE VariationResource.php - add the variation property mutator for item set variations --- src/Api/Resources/VariationResource.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Api/Resources/VariationResource.php b/src/Api/Resources/VariationResource.php index 1b24a1dda..c845dce33 100644 --- a/src/Api/Resources/VariationResource.php +++ b/src/Api/Resources/VariationResource.php @@ -47,6 +47,8 @@ public function index(): Response ] ); + $searchFactory->withPropertyGroups(); + $resultFieldTemplate = $this->request->get('resultFieldTemplate', ''); if (strlen($resultFieldTemplate)) { $searchFactory->withResultFields( From 8e833e2aea795d697b1380f857fde93d535d4c36 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Tue, 6 Oct 2020 15:50:48 +0200 Subject: [PATCH 2/7] no message --- src/Api/Resources/VariationResource.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Api/Resources/VariationResource.php b/src/Api/Resources/VariationResource.php index c845dce33..f676a02fa 100644 --- a/src/Api/Resources/VariationResource.php +++ b/src/Api/Resources/VariationResource.php @@ -43,12 +43,11 @@ public function index(): Response 'sortingOrder' => $this->request->get('sortingOrder'), 'page' => $this->request->get('page'), 'itemsPerPage' => $this->request->get('itemsPerPage'), - 'setPriceOnly' => $this->request->get('setPriceOnly') === 'true' + 'setPriceOnly' => $this->request->get('setPriceOnly') === 'true', + 'withVariationPropertyGroups' => true ] ); - $searchFactory->withPropertyGroups(); - $resultFieldTemplate = $this->request->get('resultFieldTemplate', ''); if (strlen($resultFieldTemplate)) { $searchFactory->withResultFields( From 50ecf7a66fa80666b95ef0161ad434a34fb13cf9 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Tue, 3 Nov 2020 17:19:17 +0100 Subject: [PATCH 3/7] CHANGE OrderStatusService.php - prevent loading the statuses with id lower than 1 --- src/Services/OrderStatusService.php | 41 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Services/OrderStatusService.php b/src/Services/OrderStatusService.php index ed3b00acb..1a820d14b 100644 --- a/src/Services/OrderStatusService.php +++ b/src/Services/OrderStatusService.php @@ -38,7 +38,7 @@ public function __construct(AuthHelper $authHelper, OrderStatusRepositoryContrac $this->orderStatusRepo = $orderStatusRepo; $this->statusHistoryRepo = $statusHistoryRepo; } - + /** * @param int $orderId * @param float $orderStatusId @@ -49,16 +49,17 @@ public function getOrderStatus($orderId, $orderStatusId) $lang = Utils::getLang(); $orderStatusRepo = $this->orderStatusRepo; $statusHistoryRepo = $this->statusHistoryRepo; - $logger = $this->getLogger(__CLASS__); + $logger = $this->getLogger(__CLASS__)->addReference('orderId', $orderId); $orderStatus = $this->authHelper->processUnguarded( function() use ($orderId, $orderStatusId, $lang, $orderStatusRepo, $statusHistoryRepo, $logger) { + $statusHistory = $statusHistoryRepo->getStatusHistoryByOrderId($orderId); $orderStatus = $orderStatusRepo->get($orderStatusId); - if ( !is_null($orderStatus) && $orderStatus->isFrontendVisible ) + if (!is_null($orderStatus) && $orderStatus->isFrontendVisible) { return str_replace('['.$orderStatus->statusId.']', '', $orderStatus->names->get($lang)); } - elseif( !is_null($orderStatus) ) + elseif(!is_null($orderStatus)) { $statusHistory = $statusHistoryRepo->getStatusHistoryByOrderId($orderId); if(count($statusHistory)) @@ -66,16 +67,24 @@ public function getOrderStatus($orderId, $orderStatusId) $statusHistoryNew = []; foreach($statusHistory as $entryKey => $entry) { - try - { - $statusHistoryNew[$entryKey] = $orderStatusRepo->get($entry->statusId); - }catch(\Exception $e) - { - $logger->error("IO::Debug.OrderStatusService_getOrderSatus", [ - 'code' => $e->getCode(), - 'message' => $e->getMessage() - ]); + // status with 0 means the creation of an order is not completed, caused by an error + if ($statusHistory[0]->statusId > 0) { + try + { + $newStatus = $orderStatusRepo->get($entry->statusId); + if ($newStatus->isFrontendVisible) { + $statusHistoryNew[$entryKey] = $newStatus; + } + }catch(\Exception $e) + { + $logger->error("IO::Debug.OrderStatusService_getOrderSatus", [ + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + 'entryKey' => $entryKey + ]); + + } } } @@ -92,10 +101,10 @@ public function getOrderStatus($orderId, $orderStatusId) } } } - + return ''; }); - + return $orderStatus; } -} \ No newline at end of file +} From dc2e7d25a829352b76e86f61aadde98ab891c5a6 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Tue, 3 Nov 2020 17:19:51 +0100 Subject: [PATCH 4/7] CHANGE OrderStatusService.php - reformat code --- src/Services/OrderStatusService.php | 60 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Services/OrderStatusService.php b/src/Services/OrderStatusService.php index 1a820d14b..66bcb63d5 100644 --- a/src/Services/OrderStatusService.php +++ b/src/Services/OrderStatusService.php @@ -32,8 +32,11 @@ class OrderStatusService * @param OrderStatusRepositoryContract $orderStatusRepo * @param StatusHistoryRepositoryContract $statusHistoryRepo */ - public function __construct(AuthHelper $authHelper, OrderStatusRepositoryContract $orderStatusRepo, StatusHistoryRepositoryContract $statusHistoryRepo) - { + public function __construct( + AuthHelper $authHelper, + OrderStatusRepositoryContract $orderStatusRepo, + StatusHistoryRepositoryContract $statusHistoryRepo + ) { $this->authHelper = $authHelper; $this->orderStatusRepo = $orderStatusRepo; $this->statusHistoryRepo = $statusHistoryRepo; @@ -46,38 +49,37 @@ public function __construct(AuthHelper $authHelper, OrderStatusRepositoryContrac */ public function getOrderStatus($orderId, $orderStatusId) { - $lang = Utils::getLang(); - $orderStatusRepo = $this->orderStatusRepo; - $statusHistoryRepo = $this->statusHistoryRepo; - $logger = $this->getLogger(__CLASS__)->addReference('orderId', $orderId); + $lang = Utils::getLang(); + $orderStatusRepo = $this->orderStatusRepo; + $statusHistoryRepo = $this->statusHistoryRepo; + $logger = $this->getLogger(__CLASS__)->addReference('orderId', $orderId); - $orderStatus = $this->authHelper->processUnguarded( function() use ($orderId, $orderStatusId, $lang, $orderStatusRepo, $statusHistoryRepo, $logger) - { + $orderStatus = $this->authHelper->processUnguarded(function () use ( + $orderId, + $orderStatusId, + $lang, + $orderStatusRepo, + $statusHistoryRepo, + $logger + ) { $statusHistory = $statusHistoryRepo->getStatusHistoryByOrderId($orderId); $orderStatus = $orderStatusRepo->get($orderStatusId); - if (!is_null($orderStatus) && $orderStatus->isFrontendVisible) - { - return str_replace('['.$orderStatus->statusId.']', '', $orderStatus->names->get($lang)); - } - elseif(!is_null($orderStatus)) - { + if (!is_null($orderStatus) && $orderStatus->isFrontendVisible) { + return str_replace('[' . $orderStatus->statusId . ']', '', $orderStatus->names->get($lang)); + } elseif (!is_null($orderStatus)) { $statusHistory = $statusHistoryRepo->getStatusHistoryByOrderId($orderId); - if(count($statusHistory)) - { + if (count($statusHistory)) { $statusHistoryNew = []; - foreach($statusHistory as $entryKey => $entry) - { + foreach ($statusHistory as $entryKey => $entry) { // status with 0 means the creation of an order is not completed, caused by an error if ($statusHistory[0]->statusId > 0) { - try - { + try { $newStatus = $orderStatusRepo->get($entry->statusId); if ($newStatus->isFrontendVisible) { - $statusHistoryNew[$entryKey] = $newStatus; + $statusHistoryNew[$entryKey] = $newStatus; } - }catch(\Exception $e) - { + } catch (\Exception $e) { $logger->error("IO::Debug.OrderStatusService_getOrderSatus", [ 'code' => $e->getCode(), 'message' => $e->getMessage(), @@ -88,14 +90,12 @@ public function getOrderStatus($orderId, $orderStatusId) } } - if(count($statusHistoryNew)) - { - for($i = count($statusHistoryNew)-1; $i >= 0; $i--) - { + if (count($statusHistoryNew)) { + for ($i = count($statusHistoryNew) - 1; $i >= 0; $i--) { $statusEntry = $statusHistoryNew[$i]; - if($statusEntry instanceof OrderStatus && $statusEntry->statusId < $orderStatusId && $statusEntry->isFrontendVisible) - { - return str_replace('['.$statusEntry->statusId.']', '', $statusEntry->names->get($lang)); + if ($statusEntry instanceof OrderStatus && $statusEntry->statusId < $orderStatusId && $statusEntry->isFrontendVisible) { + return str_replace('[' . $statusEntry->statusId . ']', '', + $statusEntry->names->get($lang)); } } } From fe6c88fdd2bb0e73ea2cd3b592b19d522ea514e3 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Tue, 3 Nov 2020 17:23:13 +0100 Subject: [PATCH 5/7] CHANGE OrderStatusService.php - correct debug log --- resources/lang/en/Debug.properties | 3 +++ src/Services/OrderStatusService.php | 8 ++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/lang/en/Debug.properties b/resources/lang/en/Debug.properties index 8a641346f..1977c71e2 100644 --- a/resources/lang/en/Debug.properties +++ b/resources/lang/en/Debug.properties @@ -88,6 +88,9 @@ OrderService_orderValidationError = "Error while create new order." OrderService_placeOrder = "New order created." OrderService_returnStatusNotFound = "Status for new return orders does not exist. Created return order with status 9.0" +; OrderStatusService +OrderStatusService_getOrderStatus = "Cannot load status with given id." + ; PlaceOrderController PlaceOrderController_cannotCompleteOrder = "Cannot complete checkout process: An error occurred after creating the order." PlaceOrderController_cannotPlaceOrder = "Cannot place order." diff --git a/src/Services/OrderStatusService.php b/src/Services/OrderStatusService.php index 66bcb63d5..cbfcfae7c 100644 --- a/src/Services/OrderStatusService.php +++ b/src/Services/OrderStatusService.php @@ -74,13 +74,9 @@ public function getOrderStatus($orderId, $orderStatusId) // status with 0 means the creation of an order is not completed, caused by an error if ($statusHistory[0]->statusId > 0) { try { - $newStatus = $orderStatusRepo->get($entry->statusId); - - if ($newStatus->isFrontendVisible) { - $statusHistoryNew[$entryKey] = $newStatus; - } + $statusHistoryNew[$entryKey] = $orderStatusRepo->get($entry->statusId); } catch (\Exception $e) { - $logger->error("IO::Debug.OrderStatusService_getOrderSatus", [ + $logger->error("IO::Debug.OrderStatusService_getOrderStatus", [ 'code' => $e->getCode(), 'message' => $e->getMessage(), 'entryKey' => $entryKey From 8e1a241cb21c7e8765852464a8cf966a91b7c359 Mon Sep 17 00:00:00 2001 From: cjohannsen Date: Tue, 3 Nov 2020 17:36:37 +0100 Subject: [PATCH 6/7] CHANGE OrderStatusService - remove testing code --- src/Services/OrderStatusService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/OrderStatusService.php b/src/Services/OrderStatusService.php index cbfcfae7c..0ea985880 100644 --- a/src/Services/OrderStatusService.php +++ b/src/Services/OrderStatusService.php @@ -72,7 +72,7 @@ public function getOrderStatus($orderId, $orderStatusId) $statusHistoryNew = []; foreach ($statusHistory as $entryKey => $entry) { // status with 0 means the creation of an order is not completed, caused by an error - if ($statusHistory[0]->statusId > 0) { + if ($entry->statusId > 0) { try { $statusHistoryNew[$entryKey] = $orderStatusRepo->get($entry->statusId); } catch (\Exception $e) { From b5132727733639721bbef6b8dc01cbd1a40f46ac Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Wed, 4 Nov 2020 08:42:41 +0100 Subject: [PATCH 7/7] FIX shopbuilder faker data --- .../ItemSearch/Factories/Faker/Traits/HandleNestedArray.php | 2 +- src/Services/ItemSearch/Factories/Faker/VariationFaker.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Services/ItemSearch/Factories/Faker/Traits/HandleNestedArray.php b/src/Services/ItemSearch/Factories/Faker/Traits/HandleNestedArray.php index 70ed2dbe1..f266a3926 100644 --- a/src/Services/ItemSearch/Factories/Faker/Traits/HandleNestedArray.php +++ b/src/Services/ItemSearch/Factories/Faker/Traits/HandleNestedArray.php @@ -20,7 +20,7 @@ protected function merge(&$object, $defaults) { $this->merge($object[$key], (array)$defaultValue); } - else if (is_null($object[$key])) + else if (is_null($object[$key]) || $object[$key] === 0) { $object[$key] = $defaultValue; } diff --git a/src/Services/ItemSearch/Factories/Faker/VariationFaker.php b/src/Services/ItemSearch/Factories/Faker/VariationFaker.php index 29c8b5d86..c9e17d1d7 100644 --- a/src/Services/ItemSearch/Factories/Faker/VariationFaker.php +++ b/src/Services/ItemSearch/Factories/Faker/VariationFaker.php @@ -66,7 +66,8 @@ public function fill($data) "automaticClientVisibility" => $this->number(0, 3), "automaticListVisibility" => $this->number(0, 3), "isHiddenInCategoryList" => $this->boolean(), - "availability" => $this->makeAvailability() + "availability" => $this->makeAvailability(), + "customsTariffNumber" => $this->serial() ]; $this->merge($data, $default);