From ea5c2e61486c318cbd5d7ce786420ffc1a56be17 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 14 Mar 2023 14:18:47 +0100 Subject: [PATCH] [PriceHistory][Domain] Add fields to Channel and ChannelPricing entites --- .../Resources/config/doctrine/model/Channel.orm.xml | 9 +++++++++ .../config/doctrine/model/ChannelPricing.orm.xml | 1 + src/Sylius/Component/Core/Model/Channel.php | 12 ++++++++++++ .../Component/Core/Model/ChannelInterface.php | 4 ++++ src/Sylius/Component/Core/Model/ChannelPricing.php | 13 +++++++++++++ .../Core/Model/ChannelPricingInterface.php | 4 ++++ .../Core/spec/Model/ChannelPricingSpec.php | 6 ++++++ 7 files changed, 49 insertions(+) diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Channel.orm.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Channel.orm.xml index 299b61fd5ae..4da5a8e8746 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Channel.orm.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Channel.orm.xml @@ -29,6 +29,15 @@ + + + + + diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ChannelPricing.orm.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ChannelPricing.orm.xml index 25fb4c4c84c..60c7d5a13d2 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ChannelPricing.orm.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ChannelPricing.orm.xml @@ -32,6 +32,7 @@ + diff --git a/src/Sylius/Component/Core/Model/Channel.php b/src/Sylius/Component/Core/Model/Channel.php index de78b010dc7..9092249bdc9 100644 --- a/src/Sylius/Component/Core/Model/Channel.php +++ b/src/Sylius/Component/Core/Model/Channel.php @@ -82,6 +82,8 @@ class Channel extends BaseChannel implements ChannelInterface /** @var TaxonInterface|null */ protected $menuTaxon; + protected int $lowestPriceForDiscountedProductsCheckingPeriod = 30; + public function __construct() { parent::__construct(); @@ -295,4 +297,14 @@ public function setMenuTaxon(?TaxonInterface $menuTaxon): void { $this->menuTaxon = $menuTaxon; } + + public function getLowestPriceForDiscountedProductsCheckingPeriod(): int + { + return $this->lowestPriceForDiscountedProductsCheckingPeriod; + } + + public function setLowestPriceForDiscountedProductsCheckingPeriod(int $periodInDays): void + { + $this->lowestPriceForDiscountedProductsCheckingPeriod = $periodInDays; + } } diff --git a/src/Sylius/Component/Core/Model/ChannelInterface.php b/src/Sylius/Component/Core/Model/ChannelInterface.php index 515ec7caad9..916b96d96dd 100644 --- a/src/Sylius/Component/Core/Model/ChannelInterface.php +++ b/src/Sylius/Component/Core/Model/ChannelInterface.php @@ -91,4 +91,8 @@ public function addCountry(CountryInterface $country): void; public function removeCountry(CountryInterface $country): void; public function hasCountry(CountryInterface $country): bool; + + public function getLowestPriceForDiscountedProductsCheckingPeriod(): int; + + public function setLowestPriceForDiscountedProductsCheckingPeriod(int $periodInDays): void; } diff --git a/src/Sylius/Component/Core/Model/ChannelPricing.php b/src/Sylius/Component/Core/Model/ChannelPricing.php index 8f48975bb81..09d3b6fc753 100644 --- a/src/Sylius/Component/Core/Model/ChannelPricing.php +++ b/src/Sylius/Component/Core/Model/ChannelPricing.php @@ -36,6 +36,9 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable /** @var int */ protected $minimumPrice = 0; + /** @var int|null */ + protected $lowestPriceBeforeDiscount; + /** * @var ArrayCollection * @@ -98,6 +101,16 @@ public function setOriginalPrice(?int $originalPrice): void $this->originalPrice = $originalPrice; } + public function getLowestPriceBeforeDiscount(): ?int + { + return $this->lowestPriceBeforeDiscount; + } + + public function setLowestPriceBeforeDiscount(?int $lowestPriceBeforeDiscount): void + { + $this->lowestPriceBeforeDiscount = $lowestPriceBeforeDiscount; + } + public function isPriceReduced(): bool { return $this->originalPrice > $this->price; diff --git a/src/Sylius/Component/Core/Model/ChannelPricingInterface.php b/src/Sylius/Component/Core/Model/ChannelPricingInterface.php index 9077036d8cf..0b0fdd61930 100644 --- a/src/Sylius/Component/Core/Model/ChannelPricingInterface.php +++ b/src/Sylius/Component/Core/Model/ChannelPricingInterface.php @@ -37,6 +37,10 @@ public function getOriginalPrice(): ?int; public function setOriginalPrice(?int $originalPrice): void; + public function getLowestPriceBeforeDiscount(): ?int; + + public function setLowestPriceBeforeDiscount(?int $lowestPriceBeforeDiscount): void; + public function getMinimumPrice(): int; public function setMinimumPrice(int $minimumPrice): void; diff --git a/src/Sylius/Component/Core/spec/Model/ChannelPricingSpec.php b/src/Sylius/Component/Core/spec/Model/ChannelPricingSpec.php index 9b74218ca35..5b74f6ef620 100644 --- a/src/Sylius/Component/Core/spec/Model/ChannelPricingSpec.php +++ b/src/Sylius/Component/Core/spec/Model/ChannelPricingSpec.php @@ -55,6 +55,12 @@ function its_original_price_is_mutable(): void $this->getOriginalPrice()->shouldReturn(2000); } + function its_lowest_price_before_discount_is_mutable(): void + { + $this->setLowestPriceBeforeDiscount(2000); + $this->getLowestPriceBeforeDiscount()->shouldReturn(2000); + } + function its_price_can_be_reduced(): void { $this->setPrice(1000);