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/Api/Resources/VariationResource.php b/src/Api/Resources/VariationResource.php index 1b24a1dda..f676a02fa 100644 --- a/src/Api/Resources/VariationResource.php +++ b/src/Api/Resources/VariationResource.php @@ -43,7 +43,8 @@ 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 ] ); 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); diff --git a/src/Services/OrderStatusService.php b/src/Services/OrderStatusService.php index ed3b00acb..0ea985880 100644 --- a/src/Services/OrderStatusService.php +++ b/src/Services/OrderStatusService.php @@ -32,13 +32,16 @@ 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; } - + /** * @param int $orderId * @param float $orderStatusId @@ -46,56 +49,58 @@ public function __construct(AuthHelper $authHelper, OrderStatusRepositoryContrac */ public function getOrderStatus($orderId, $orderStatusId) { - $lang = Utils::getLang(); - $orderStatusRepo = $this->orderStatusRepo; - $statusHistoryRepo = $this->statusHistoryRepo; - $logger = $this->getLogger(__CLASS__); + $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) - { - try - { - $statusHistoryNew[$entryKey] = $orderStatusRepo->get($entry->statusId); - }catch(\Exception $e) - { - $logger->error("IO::Debug.OrderStatusService_getOrderSatus", [ - 'code' => $e->getCode(), - 'message' => $e->getMessage() - ]); + foreach ($statusHistory as $entryKey => $entry) { + // status with 0 means the creation of an order is not completed, caused by an error + if ($entry->statusId > 0) { + try { + $statusHistoryNew[$entryKey] = $orderStatusRepo->get($entry->statusId); + } catch (\Exception $e) { + $logger->error("IO::Debug.OrderStatusService_getOrderStatus", [ + 'code' => $e->getCode(), + 'message' => $e->getMessage(), + 'entryKey' => $entryKey + ]); + } } } - 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)); } } } } } - + return ''; }); - + return $orderStatus; } -} \ No newline at end of file +}