mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[PriceHistory][Domain] Add fields to Channel and ChannelPricing entites
This commit is contained in:
parent
87f4dc81b5
commit
ea5c2e6148
7 changed files with 49 additions and 0 deletions
|
|
@ -29,6 +29,15 @@
|
|||
<option name="default">0</option>
|
||||
</options>
|
||||
</field>
|
||||
<field
|
||||
name="lowestPriceForDiscountedProductsCheckingPeriod"
|
||||
column="lowest_price_for_discounted_products_checking_period"
|
||||
type="boolean"
|
||||
>
|
||||
<options>
|
||||
<option name="default">30</option>
|
||||
</options>
|
||||
</field>
|
||||
|
||||
<many-to-one field="defaultLocale" target-entity="Sylius\Component\Locale\Model\LocaleInterface" fetch="EAGER">
|
||||
<join-column name="default_locale_id" referenced-column-name="id" nullable="false" />
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<option name="default">0</option>
|
||||
</options>
|
||||
</field>
|
||||
<field name="lowestPriceBeforeDiscount" column="lowest_price_before_discount" type="integer" nullable="true" />
|
||||
<field name="channelCode" column="channel_code" type="string" />
|
||||
<many-to-many field="appliedPromotions" target-entity="Sylius\Component\Promotion\Model\CatalogPromotionInterface">
|
||||
<order-by>
|
||||
|
|
|
|||
|
|
@ -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 @@ class Channel extends BaseChannel implements ChannelInterface
|
|||
{
|
||||
$this->menuTaxon = $menuTaxon;
|
||||
}
|
||||
|
||||
public function getLowestPriceForDiscountedProductsCheckingPeriod(): int
|
||||
{
|
||||
return $this->lowestPriceForDiscountedProductsCheckingPeriod;
|
||||
}
|
||||
|
||||
public function setLowestPriceForDiscountedProductsCheckingPeriod(int $periodInDays): void
|
||||
{
|
||||
$this->lowestPriceForDiscountedProductsCheckingPeriod = $periodInDays;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,4 +91,8 @@ interface ChannelInterface extends
|
|||
public function removeCountry(CountryInterface $country): void;
|
||||
|
||||
public function hasCountry(CountryInterface $country): bool;
|
||||
|
||||
public function getLowestPriceForDiscountedProductsCheckingPeriod(): int;
|
||||
|
||||
public function setLowestPriceForDiscountedProductsCheckingPeriod(int $periodInDays): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable
|
|||
$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;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ interface ChannelPricingInterface extends ResourceInterface
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ final class ChannelPricingSpec extends ObjectBehavior
|
|||
$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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue