1616use Sylius \Component \Core \Model \CatalogPromotionInterface ;
1717use Sylius \Component \Core \Model \ProductInterface ;
1818use Sylius \Component \Core \Model \ProductVariantInterface ;
19- use Sylius \Component \Core \Provider \CatalogPromotionProductsProviderInterface ;
19+ use Sylius \Component \Core \Provider \CatalogPromotionVariantsProviderInterface ;
2020use Sylius \Component \Core \Repository \ProductVariantRepositoryInterface ;
2121use Sylius \Component \Promotion \Model \CatalogPromotionRuleInterface ;
2222
23- final class CatalogPromotionProductsProvider implements CatalogPromotionProductsProviderInterface
23+ final class CatalogPromotionVariantsProvider implements CatalogPromotionVariantsProviderInterface
2424{
2525 private ProductVariantRepositoryInterface $ productVariantRepository ;
2626
@@ -29,22 +29,22 @@ public function __construct(ProductVariantRepositoryInterface $productVariantRep
2929 $ this ->productVariantRepository = $ productVariantRepository ;
3030 }
3131
32- public function provideEligibleProducts (CatalogPromotionInterface $ catalogPromotion ): array
32+ public function provideEligibleVariants (CatalogPromotionInterface $ catalogPromotion ): array
3333 {
34- $ products = [];
34+ $ variants = [];
3535
3636 /** @var CatalogPromotionRuleInterface $rule */
3737 foreach ($ catalogPromotion ->getRules () as $ rule ) {
3838 $ configuration = $ rule ->getConfiguration ();
3939
4040 /** We can do that for now, as we have only one rule */
41- $ products = $ this ->getVariantsProducts ($ configuration , $ products );
41+ $ variants = $ this ->getVariantsProducts ($ configuration , $ variants );
4242 }
4343
44- return $ products ;
44+ return $ variants ;
4545 }
4646
47- private function getVariantsProducts (array $ configuration , array $ products ): array
47+ private function getVariantsProducts (array $ configuration , array $ variants ): array
4848 {
4949 /** @var string $variantCode */
5050 foreach ($ configuration as $ variantCode ) {
@@ -54,13 +54,11 @@ private function getVariantsProducts(array $configuration, array $products): arr
5454 continue ;
5555 }
5656
57- /** @var ProductInterface $product */
58- $ product = $ variant ->getProduct ();
59- if (!in_array ($ product , $ products )) {
60- $ products [] = $ product ;
57+ if (!in_array ($ variant , $ variants )) {
58+ $ variants [] = $ variant ;
6159 }
6260 }
6361
64- return $ products ;
62+ return $ variants ;
6563 }
6664}
0 commit comments