zanzan MemberComments: 0 Received thanks: 0 Member since: December 2020

I am following this video https://academy.shopware.com/courses/take/shopware-6-developer-training-english/lessons/9225170-data-storefront

 

According the this video, before creating any `twig` file `http://localhost:8000/` should render page without footer. But I have been following every steps and in my case it renders everything.

Please refer to my `FooterSubscriber.php` page:

 

class FooterSubscriber implements EventSubscriberInterface
{
    /**
     * @var SystemConfigService
     */
    private $systemConfigService;
    /**
     * @var EntityRepositoryInterface
     */
    private $shopFinderRepository;

    /**
     * FooterSubscriber constructor.
     * @param SystemConfigService       $systemConfigService
     * @param EntityRepositoryInterface $shopFinderRepository
     */
    public function __construct(SystemConfigService $systemConfigService, EntityRepositoryInterface $shopFinderRepository)
    {
        $this->systemConfigService = $systemConfigService;
        $this->shopFinderRepository = $shopFinderRepository;
    }

    public static function getSubscribedEvents(): array
    {
        return [
            FooterPageletLoadedEvent::class => 'onFooterPageLoaded'
        ];
    }

    public function onFooterPageLoaded(FooterPageletLoadedEvent $event): void
    {
        if (!$this->systemConfigService->get('Storefront.config.showInStoreFront')) {
            return;
        }
        $shops = $this->fetchShops($event->getContext());

        $event->getPagelet()->addExtension('swag_shop_finder', $shops);
    }

    /**
     * @param Context $context
     * @return ShopFinderCollection
     */
    private function fetchShops(Context $context): ShopFinderCollection
    {
        $criteria = new Criteria();
        $criteria->addAssociation('country');
        $criteria->addFilter(new EqualsFilter('active', 1));
        $criteria->setLimit(5);

        /**
         * @var ShopFinderCollection $shopFinderCollection
         */
        $shopFinderCollection = $this->shopFinderRepository->search($criteria, $context);

        return $shopFinderCollection;
    }
}

 

config.xml

 

<?xml version="1.0" encoding="UTF-8"?>


    
        Basic configuration
        German Title

        
            showInStorefront
            
            
        
    

Sign In or Register to comment.