Skip to content

Commit

Permalink
[PriceHistory][Domain] Add fields to Channel and ChannelPricing entites
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafikooo committed Mar 17, 2023
1 parent 87f4dc8 commit ea5c2e6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 12 additions & 0 deletions src/Sylius/Component/Core/Model/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Channel extends BaseChannel implements ChannelInterface
/** @var TaxonInterface|null */
protected $menuTaxon;

protected int $lowestPriceForDiscountedProductsCheckingPeriod = 30;

public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -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;
}
}
4 changes: 4 additions & 0 deletions src/Sylius/Component/Core/Model/ChannelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 13 additions & 0 deletions src/Sylius/Component/Core/Model/ChannelPricing.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ChannelPricing implements ChannelPricingInterface, \Stringable
/** @var int */
protected $minimumPrice = 0;

/** @var int|null */
protected $lowestPriceBeforeDiscount;

/**
* @var ArrayCollection
*
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/Sylius/Component/Core/Model/ChannelPricingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/Sylius/Component/Core/spec/Model/ChannelPricingSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ea5c2e6

Please sign in to comment.