getMetaInformation example


    public function metaDownloadAction()
    {
        try {
            $request = new MetaRequest(
                $this->Request()->getParam('technicalName'),
                $this->getVersion(),
                $this->getDomain(),
                $this->getAccessToken()
            );

            $result = $this->get('shopware_plugininstaller.plugin_download_service')->getMetaInformation($request);
            $this->get('backendsession')->offsetSet('plugin_manager_meta_download', $result);
        } catch (Exception $e) {
            $this->handleException($e);

            return;
        }

        $this->View()->assign(['success' => true, 'data' => $result]);
    }

    /** * @return void */


    public function load(Request $request, SalesChannelContext $salesChannelContext): CustomerGroupRegistrationPage
    {
        $page = CustomerGroupRegistrationPage::createFrom($this->accountLoginPageLoader->load($request$salesChannelContext));
        $customerGroupId = $request->attributes->get('customerGroupId');

        $page->setGroup(
            $this->customerGroupRegistrationRoute->load($customerGroupId$salesChannelContext)->getRegistration()
        );

        if ($page->getMetaInformation()) {
            $metaDescription = $page->getGroup()->getTranslation('registrationSeoMetaDescription');
            if ($metaDescription) {
                $page->getMetaInformation()->setMetaDescription($metaDescription);
            }

            $title = $page->getGroup()->getTranslation('registrationTitle');
            if ($title) {
                $page->getMetaInformation()->setMetaTitle($title);
            }
        }

        
$order = $result->getOrders()->first();

        if (!$order instanceof OrderEntity) {
            throw new NotFoundHttpException();
        }

        $page = AccountOrderDetailPage::createFrom($this->genericLoader->load($request$salesChannelContext));
        $page->setLineItems($order->getNestedLineItems());
        $page->setOrder($order);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $this->eventDispatcher->dispatch(
            new AccountOrderDetailPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }
}

    public function load(Request $request, SalesChannelContext $salesChannelContext, CustomerEntity $customer): AccountOverviewPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AccountOverviewPage::createFrom($page);
        $page->setCustomer($this->loadCustomer($salesChannelContext$customer));

        $page->getMetaInformation()?->setRobots('noindex,follow');

        $order = $this->loadNewestOrder($salesChannelContext$request);

        if ($order !== null) {
            $page->setNewestOrder($order);
        }

        $newslAccountPagelet = $this->newsletterAccountPageletLoader->load($request$salesChannelContext$customer);

        $page->setNewsletterAccountPagelet($newslAccountPagelet);

        

        $request = new Request(['search' => self::TEST_TERM]);

        $context = $this->createSalesChannelContextWithNavigation();

        /** @var SearchPageLoadedEvent $homePageLoadedEvent */
        $homePageLoadedEvent = null;
        $this->catchEvent(SearchPageLoadedEvent::class$homePageLoadedEvent);

        $page = $this->getPageLoader()->load($request$context);

        static::assertSame('Demostore', $page->getMetaInformation()->getMetaTitle());

        $systemConfig = $this->getContainer()->get(SystemConfigService::class);
        $systemConfig->set('core.basicInformation.shopName', 'Teststore', $context->getSalesChannel()->getId());

        $page = $this->getPageLoader()->load($request$context);

        static::assertSame('Teststore', $page->getMetaInformation()->getMetaTitle());
    }

    /** * @return SearchPageLoader */
public function load(Request $request, SalesChannelContext $salesChannelContext): AccountOrderPage
    {
        if (!$salesChannelContext->getCustomer() && $request->get('deepLinkCode', false) === false) {
            throw CartException::customerNotLoggedIn();
        }

        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AccountOrderPage::createFrom($page);

        $page->getMetaInformation()?->setRobots('noindex,follow');

        $page->setOrders(StorefrontSearchResult::createFrom($this->getOrders($request$salesChannelContext)));

        $page->setDeepLinkCode($request->get('deepLinkCode'));

        $firstOrder = $page->getOrders()->getEntities()->first();
        $orderCustomerId = $firstOrder?->getOrderCustomer()?->getCustomer()?->getId();
        if ($request->get('deepLinkCode') && $orderCustomerId !== null) {
            $this->accountService->loginById(
                $orderCustomerId,
                $salesChannelContext
            );

    public function load(Request $request, SalesChannelContext $salesChannelContext, CustomerEntity $customer): AddressDetailPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AddressDetailPage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $page->setSalutations($this->getSalutations($salesChannelContext));

        $page->setCountries($this->getCountries($salesChannelContext));

        $page->setAddress($this->getAddress($request$salesChannelContext$customer));

        $this->eventDispatcher->dispatch(
            new AddressDetailPageLoadedEvent($page$salesChannelContext$request)
        );

    public function load(Request $request, SalesChannelContext $salesChannelContext): AccountProfilePage
    {
        if ($salesChannelContext->getCustomer() === null) {
            throw CartException::customerNotLoggedIn();
        }

        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AccountProfilePage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $page->setSalutations($this->getSalutations($salesChannelContext$request));

        $this->eventDispatcher->dispatch(
            new AccountProfilePageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }

    
/** * @throws CategoryNotFoundException * @throws InconsistentCriteriaIdsException * @throws RoutingException */
    public function load(Request $request, SalesChannelContext $salesChannelContext): OffcanvasCartPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = OffcanvasCartPage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->assign(['robots' => 'noindex,follow']);
        }

        $page->setCart($this->cartService->get($salesChannelContext->getToken()$salesChannelContext));

        $page->setShippingMethods($this->getShippingMethods($salesChannelContext));

        $this->eventDispatcher->dispatch(
            new OffcanvasCartPageLoadedEvent($page$salesChannelContext$request)
        );

        
/** * @throws CategoryNotFoundException * @throws InconsistentCriteriaIdsException * @throws RoutingException */
    public function load(Request $request, SalesChannelContext $salesChannelContext): SearchPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);
        $page = SearchPage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        if (!$request->query->has('search')) {
            throw RoutingException::missingRequestParameter('search');
        }

        $criteria = new Criteria();
        $criteria->setTitle('search-page');

        $result = $this->productSearchRoute
            
$this->loadMetaData($category$page$context->getSalesChannel());
        $page->setNavigationId($category->getId());

        if ($category->getCmsPage()) {
            $page->setCmsPage($category->getCmsPage());
        }

        $this->eventDispatcher->dispatch(
            new NavigationPageLoadedEvent($page$context$request)
        );

        if ($page->getMetaInformation()) {
            $canonical = ($navigationId === $context->getSalesChannel()->getNavigationCategoryId())
                ? $this->seoUrlReplacer->generate('frontend.home.page')
                : $this->seoUrlReplacer->generate('frontend.navigation.page', ['navigationId' => $navigationId]);

            $page->getMetaInformation()->setCanonical($canonical);
        }

        return $page;
    }

    private function loadMetaData(CategoryEntity $category, NavigationPage $page, SalesChannelEntity $salesChannel): void
    {
$pageLoader,
            $this->createMock(AddressValidationFactory::class),
            $this->createMock(DataValidator::class)
        );

        $page = $checkoutConfirmPageLoader->load(
            new Request(),
            $this->getContextWithDummyCustomer()
        );

        static::assertInstanceOf(CheckoutConfirmPage::class$page);
        static::assertNotNull($page->getMetaInformation());
        static::assertSame('noindex,follow', $page->getMetaInformation()->getRobots());
    }

    public function testRobotsMetaNotSetIfGiven(): void
    {
        $page = new CheckoutConfirmPage();

        $pageLoader = $this->createMock(GenericPageLoader::class);
        $pageLoader
            ->method('load')
            ->willReturn($page);

        

    public function download(DownloadRequest $request)
    {
        $metaRequest = new MetaRequest(
            $request->getTechnicalName(),
            $request->getShopwareVersion(),
            $request->getDomain(),
            $request->getToken()
        );

        $result = $this->getMetaInformation($metaRequest);

        $response = $this->httpClient->get($result->getUri());
        $file = $this->createDownloadZip($response->getBody());

        $this->extractPluginZip($file$metaRequest->getTechnicalName());
        unlink($file);

        return true;
    }

    /** * @return string file path to the downloaded file */
/** * @throws CategoryNotFoundException * @throws InconsistentCriteriaIdsException * @throws RoutingException */
    public function load(Request $request, SalesChannelContext $salesChannelContext): AccountLoginPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AccountLoginPage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $page->setCountries($this->getCountries($salesChannelContext));

        $page->setSalutations($this->getSalutations($salesChannelContext));

        $this->eventDispatcher->dispatch(
            new AccountLoginPageLoadedEvent($page$salesChannelContext$request)
        );

        
$this->createMock(StorefrontCartFacade::class),
            $pageLoader,
            $this->createMock(ShippingMethodRoute::class)
        );

        $page = $offcanvasCartPageLoader->load(
            new Request(),
            $this->createMock(SalesChannelContext::class)
        );

        static::assertInstanceOf(OffcanvasCartPage::class$page);
        static::assertNotNull($page->getMetaInformation());
        static::assertSame('noindex,follow', $page->getMetaInformation()->getRobots());
    }

    public function testRobotsMetaNotSetIfGiven(): void
    {
        $page = new OffcanvasCartPage();

        $pageLoader = $this->createMock(GenericPageLoader::class);
        $pageLoader
            ->method('load')
            ->willReturn($page);

        
Home | Imprint | This part of the site doesn't use cookies.