-
Run:
composer require sylius/price-history-plugin --no-scripts
-
Add the following line to the
packages/bundles.php
Sylius\PriceHistoryPlugin\SyliusPriceHistoryPlugin::class => ['all' => true]
-
The
Channel
entity should implement the following interface:Sylius\PriceHistoryPlugin\Domain\Model\ChannelInterface
and use trait:
Sylius\PriceHistoryPlugin\Domain\Model\ChannelPriceHistoryConfigAwareTrait;
Final result:
<?php declare(strict_types=1); namespace App\Entity\Channel; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Channel as BaseChannel; use Sylius\PriceHistoryPlugin\Domain\Model\ChannelInterface; use Sylius\PriceHistoryPlugin\Domain\Model\ChannelPriceHistoryConfigAwareTrait; /** * @ORM\Entity * @ORM\Table(name="sylius_channel") */ #[ORM\Entity] #[ORM\Table(name: 'sylius_channel')] class Channel extends BaseChannel implements ChannelInterface { use ChannelPriceHistoryConfigAwareTrait; }
-
The
ChannelPricing
entity should implement the following interface:Sylius\PriceHistoryPlugin\Domain\Model\ChannelPricingInterface
and use trait:
Sylius\PriceHistoryPlugin\Domain\Model\LowestPriceBeforeDiscountAwareTrait
Final result:
<?php declare(strict_types=1); namespace App\Entity\Channel; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\ChannelPricing as BaseChannelPricing; use Sylius\PriceHistoryPlugin\Domain\Model\ChannelPricingInterface; use Sylius\PriceHistoryPlugin\Domain\Model\LowestPriceBeforeDiscountAwareTrait; /** * @ORM\Entity * @ORM\Table(name="sylius_channel_pricing") */ #[ORM\Entity] #[ORM\Table(name: 'sylius_channel_pricing')] class ChannelPricing extends BaseChannelPricing implements ChannelPricingInterface { use LowestPriceBeforeDiscountAwareTrait; }
-
Ensure you have modified resource configured in
config/packages/_sylius.yaml
:sylius_channel: resources: channel: classes: model: App\Entity\Channel\Channel sylius_core: resources: channel_pricing: classes: model: App\Entity\Channel\ChannelPricing
-
Import configuration to
config/packages/_sylius.yaml
:imports: - { resource: "@SyliusPriceHistoryPlugin/config/config.yaml" }
-
Configure routing in
config/routes/sylius_admin.yaml
:sylius_price_history_admin: resource: "@SyliusPriceHistoryPlugin/config/admin_routing.yaml" prefix: '/%sylius_admin.path_name%'
-
Execute migrations:
bin/console doctrine:migrations:migrate
-
Rebuild the cache to display all new translations correctly:
bin/console cache:clear bin/console cache:warmup
-
Run messenger consumer:
bin/console messenger:consume main
For more information check official Symfony docs.