From 3ea135484ecd2d31d08e8777e2ca5ae4ed2f2577 Mon Sep 17 00:00:00 2001 From: Thomas Hampe Date: Wed, 15 Oct 2025 00:14:33 +0200 Subject: [PATCH] Fix for #41 Since the validation can be called mulitple times, the same product can not be added to the cart. so we need to enforce a new object when querying the repository (last parameter). This should fix the open issue #41 --- SalesRule/Action/AbstractGiftAction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SalesRule/Action/AbstractGiftAction.php b/SalesRule/Action/AbstractGiftAction.php index ff3bb19..05d21fa 100644 --- a/SalesRule/Action/AbstractGiftAction.php +++ b/SalesRule/Action/AbstractGiftAction.php @@ -206,7 +206,7 @@ protected function addAppliedRuleId(DataObject $stateObject, Rule $rule): void protected function getGiftProduct(string $sku): ProductInterface { /** @var Product $product */ - $product = $this->productRepository->get($sku); + $product = $this->productRepository->get($sku, false, null, true); /** * Makes it unique, to avoid merging * @see \Magento\Quote\Model\Quote\Item::representProduct @@ -232,4 +232,4 @@ protected function getDiscountData(AbstractItem $item): Discount\Data 'baseOriginalAmount' => $item->getBaseOriginalDiscountAmount() ]); } -} \ No newline at end of file +}