<?php
namespace EnetProductStoreSalesChannel\Subscriber;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
use Shopware\Storefront\Page\PageLoadedEvent;
use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
use Shopware\Storefront\Pagelet\PageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class TestSubscriber implements EventSubscriberInterface
{
/** @var SalesChannelRepository $salesChannelRepository */
private $salesChannelRepository;
private $container;
public function __construct(EntityRepository $salesChannelRepository, $container)
{
$this->salesChannelRepository = $salesChannelRepository;
$this->container = $container;
}
public static function getSubscribedEvents()
{
return [
HeaderPageletLoadedEvent::class => 'onSalesChannelLoaded',
];
}
public function onSalesChannelLoaded(PageletLoadedEvent $event)
{
// /** @var EntityRepositoryInterface $repo */
// $repo = $this->container->get('enet_product_saleschannel_stock.repository');
// $cust = $repo->search(
// (new Criteria())->addFilter(new EqualsFilter('disabled', true)),
// Context::createDefaultContext()
// );
// dump($cust->getElements()); die();
}
}