Skip to content

Commit

Permalink
MP-6714 Fixed displaying product offers in wishlist. (#2200)
Browse files Browse the repository at this point in the history
MP-6714 Fix adding product offer to wishlist
  • Loading branch information
ilantipov authored Apr 22, 2022
1 parent 39fbd4e commit 86976ba
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ protected function prepareConcreteProduct(
ProductViewTransfer $productViewTransfer,
array $productConcreteStorageData
): ProductViewTransfer {
$productViewTransfer->fromArray($productConcreteStorageData, true);
$productViewTransfer = $this->mapProductConcreteStorageDataToProductViewTransfer(
$productConcreteStorageData,
$productViewTransfer,
);

return $this->getFactory()
->createWishlistItemExpander()
Expand All @@ -406,6 +409,26 @@ protected function prepareConcreteProduct(
);
}

/**
* @param array<mixed> $productConcreteStorageData
* @param \Generated\Shared\Transfer\ProductViewTransfer $productViewTransfer
*
* @return \Generated\Shared\Transfer\ProductViewTransfer
*/
protected function mapProductConcreteStorageDataToProductViewTransfer(
array $productConcreteStorageData,
ProductViewTransfer $productViewTransfer
): ProductViewTransfer {
$productViewData = array_replace(
$productConcreteStorageData,
array_filter($productViewTransfer->toArray(), function ($value) {
return $value !== null;
}),
);

return $productViewTransfer->fromArray($productViewData, true);
}

/**
* @param \Generated\Shared\Transfer\WishlistItemTransfer $wishlistItemTransfer
*
Expand Down

0 comments on commit 86976ba

Please sign in to comment.