Skip to content

Commit

Permalink
CC-13972 - Fixed multistore product reservation. (#8444)
Browse files Browse the repository at this point in the history
CC-13972 - Fixed multistore product reservation.
  • Loading branch information
pavelmaksimov25 authored Jul 15, 2021
1 parent 3426456 commit b57810e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Spryker/Zed/Oms/Business/Reader/ReservationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ public function getOmsReservedProductQuantity(ReservationRequestTransfer $reserv
public function sumReservedProductQuantities(ReservationRequestTransfer $reservationRequestTransfer): Decimal
{
$reservedStates = $this->getOmsReservedStateCollection();
$reservationRequestTransfer->setReservedStates($reservedStates);

$reservationRequestTransfer->setReservedStates($reservedStates)
->setStore($this->storeFacade->getCurrentStore());
$salesOrderItemStateAggregationTransfers = $this->aggregateReservations($reservationRequestTransfer);

return $this->calculateReservationQuantity(
Expand Down
12 changes: 9 additions & 3 deletions src/Spryker/Zed/Oms/Business/Util/Reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,21 @@ public function updateReservationQuantity($sku)
*/
public function updateReservation(ReservationRequestTransfer $reservationRequestTransfer): void
{
$reservationQuantity = $this->reservationReader->sumReservedProductQuantities($reservationRequestTransfer);
$currentStoreTransfer = $this->storeFacade->getCurrentStore();
$reservationRequestTransfer->setReservationQuantity($reservationQuantity)
->setStore($currentStoreTransfer);
$reservationRequestTransfer->setStore($currentStoreTransfer);

$reservationQuantity = $this->reservationReader->sumReservedProductQuantities($reservationRequestTransfer);
$reservationRequestTransfer->setReservationQuantity($reservationQuantity);

$this->writeReservation($reservationRequestTransfer);

foreach ($currentStoreTransfer->getStoresWithSharedPersistence() as $storeName) {
$storeTransfer = $this->storeFacade->getStoreByName($storeName);
$reservationRequestTransfer->setStore($storeTransfer);

$reservationQuantity = $this->reservationReader->sumReservedProductQuantities($reservationRequestTransfer);
$reservationRequestTransfer->setReservationQuantity($reservationQuantity);

$this->writeReservation($reservationRequestTransfer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ public function testSumReservedProductQuantitiesShouldSumAllItemsInReservedState
$totalQuantity += $orderItem->getQuantity();
}

$currentStore = $this->getStoreFacade()->getCurrentStore();
$reservationRequestTransfer = (new ReservationRequestTransfer())
->setSku($itemSku);
->setSku($itemSku)
->setStore($currentStore);

$reservationReader = (new OmsBusinessFactory())->createReservationReader();
$reservedSubprocessItemStateEntity = $this->tester->haveOmsOrderItemStateEntity(static::RESERVED_SUBPROCESS_ITEM_STATE);
Expand Down

0 comments on commit b57810e

Please sign in to comment.