From f408ce6bbb1e101478d7b8178540f76315dbf9ff Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Fri, 10 Jan 2025 13:38:01 +0100 Subject: [PATCH 1/3] make Price, ProductPrice, and ProductSellingPrice classes final --- src/Model/FeedItem/GoogleFeedItem.php | 10 +++++----- src/Model/FeedItem/GoogleFeedItemFactory.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Model/FeedItem/GoogleFeedItem.php b/src/Model/FeedItem/GoogleFeedItem.php index a3d847ddc..8d26892b1 100644 --- a/src/Model/FeedItem/GoogleFeedItem.php +++ b/src/Model/FeedItem/GoogleFeedItem.php @@ -6,7 +6,7 @@ use Shopsys\FrameworkBundle\Model\Feed\FeedItemInterface; use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; -use Shopsys\FrameworkBundle\Model\Pricing\Price; +use Shopsys\FrameworkBundle\Model\Pricing\PriceInterface; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice; class GoogleFeedItem implements FeedItemInterface @@ -20,7 +20,7 @@ class GoogleFeedItem implements FeedItemInterface * @param int $id * @param string $name * @param bool $sellingDenied - * @param \Shopsys\FrameworkBundle\Model\Pricing\Price $price + * @param \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface $price * @param \Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice|null $specialPrice * @param \Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency $currency * @param string $url @@ -34,7 +34,7 @@ public function __construct( protected readonly int $id, protected readonly string $name, protected readonly bool $sellingDenied, - protected readonly Price $price, + protected readonly PriceInterface $price, protected readonly ?SpecialPrice $specialPrice, protected readonly Currency $currency, protected readonly string $url, @@ -111,9 +111,9 @@ public function getAvailability(): string } /** - * @return \Shopsys\FrameworkBundle\Model\Pricing\Price + * @return \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface */ - public function getPrice(): Price + public function getPrice(): PriceInterface { return $this->price; } diff --git a/src/Model/FeedItem/GoogleFeedItemFactory.php b/src/Model/FeedItem/GoogleFeedItemFactory.php index 6e46764be..a1cf66901 100644 --- a/src/Model/FeedItem/GoogleFeedItemFactory.php +++ b/src/Model/FeedItem/GoogleFeedItemFactory.php @@ -7,11 +7,11 @@ use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig; use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; -use Shopsys\FrameworkBundle\Model\Pricing\Price; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPriceFacade; use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade; use Shopsys\FrameworkBundle\Model\Product\Collection\ProductUrlsBatchLoader; +use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPrice; use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPriceCalculationForCustomerUser; use Shopsys\FrameworkBundle\Model\Product\Product; @@ -70,9 +70,9 @@ protected function getBrandName(Product $product): ?string /** * @param \Shopsys\FrameworkBundle\Model\Product\Product $product * @param \Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig $domainConfig - * @return \Shopsys\FrameworkBundle\Model\Pricing\Price + * @return \Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPrice */ - protected function getPrice(Product $product, DomainConfig $domainConfig): Price + protected function getPrice(Product $product, DomainConfig $domainConfig): ProductPrice { return $this->productPriceCalculationForCustomerUser->calculateBasicPriceForCustomerUserAndDomainId( $product, From c33de12144df27b6910f563f15d21fd8387e9d66 Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Tue, 14 Jan 2025 16:34:53 +0100 Subject: [PATCH 2/3] remove ProductSellingPrice - add pricing group to ProductPrice that is now used instead of ProductSellingPrice --- tests/Unit/GoogleFeedItemTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Unit/GoogleFeedItemTest.php b/tests/Unit/GoogleFeedItemTest.php index b935875e3..65d4fd007 100644 --- a/tests/Unit/GoogleFeedItemTest.php +++ b/tests/Unit/GoogleFeedItemTest.php @@ -11,6 +11,7 @@ use Shopsys\FrameworkBundle\Component\Money\Money; use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; +use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup; use Shopsys\FrameworkBundle\Model\Pricing\Price; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPriceFacade; use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade; @@ -132,7 +133,7 @@ private function createDomainConfigMock(int $id, string $url, string $locale, Cu */ private function mockProductPrice(Product $product, DomainConfig $domain, Price $price): void { - $productPrice = new ProductPrice($price, false); + $productPrice = new ProductPrice($price, $this->createMock(PricingGroup::class), false); $this->productPriceCalculationForCustomerUserMock->method('calculateBasicPriceForCustomerUserAndDomainId') ->with($product, $domain->getId(), null)->willReturn($productPrice); } From 355ed1fdfe5466a3554b03b4e3b071c98b121091 Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Thu, 16 Jan 2025 15:59:49 +0100 Subject: [PATCH 3/3] use (Product)PriceInterface instead of (Product)Price in the codebase --- src/Model/FeedItem/GoogleFeedItemFactory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Model/FeedItem/GoogleFeedItemFactory.php b/src/Model/FeedItem/GoogleFeedItemFactory.php index a1cf66901..514545927 100644 --- a/src/Model/FeedItem/GoogleFeedItemFactory.php +++ b/src/Model/FeedItem/GoogleFeedItemFactory.php @@ -7,11 +7,11 @@ use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig; use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; +use Shopsys\FrameworkBundle\Model\Pricing\PriceInterface; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPrice; use Shopsys\FrameworkBundle\Model\Pricing\SpecialPrice\SpecialPriceFacade; use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade; use Shopsys\FrameworkBundle\Model\Product\Collection\ProductUrlsBatchLoader; -use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPrice; use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPriceCalculationForCustomerUser; use Shopsys\FrameworkBundle\Model\Product\Product; @@ -70,14 +70,14 @@ protected function getBrandName(Product $product): ?string /** * @param \Shopsys\FrameworkBundle\Model\Product\Product $product * @param \Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig $domainConfig - * @return \Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPrice + * @return \Shopsys\FrameworkBundle\Model\Pricing\PriceInterface */ - protected function getPrice(Product $product, DomainConfig $domainConfig): ProductPrice + protected function getPrice(Product $product, DomainConfig $domainConfig): PriceInterface { return $this->productPriceCalculationForCustomerUser->calculateBasicPriceForCustomerUserAndDomainId( $product, $domainConfig->getId(), - ); + )->getPrice(); } /**