use Setono\SyliusCatalogPromotionPlugin\Context\StaticChannelContext;
use Sylius\Component\Channel\Model\ChannelInterface;
class YourFeedProcessor
{
public function __construct(private readonly StaticChannelContext $staticChannelContext) {
}
public function process(): void
{
/**
* A list of channels you need to process
*
* @var list<ChannelInterface> $channels
*/
$channels = [];
foreach ($channels as $channel) {
$this->staticChannelContext->setChannel($channel);
// do your processing...
}
}
}
use Setono\SyliusCatalogPromotionPlugin\Checker\OnSale\OnSaleCheckerInterface;
use Setono\SyliusCatalogPromotionPlugin\Model\ProductInterface;
class YourFeedProcessor
{
public function __construct(private readonly OnSaleCheckerInterface $onSaleChecker) {
}
public function process(): void
{
/**
* A list of products you are processing
*
* @var list<ProductInterface> $products
*/
$products = [];
foreach ($products as $product) {
if($this->onSaleChecker->onSale($product)) {
// the product is on sale
}
}
}
}