getExternalLink example


    public function testLinkType(?string $type, string $route): void
    {
        $category = new CategoryEntity();
        $category->setType(CategoryDefinition::TYPE_LINK);
        $category->setLinkType($type);
        $category->addTranslated('linkType', $type);

        static::assertNull($this->urlGenerator->generate($category$this->salesChannel));

        $category->setExternalLink(self::EXTERNAL_URL);
        $category->addTranslated('externalLink', $category->getExternalLink());
        $category->setInternalLink(Uuid::randomHex());
        $category->addTranslated('internalLink', $category->getInternalLink());

        static::assertSame($route$this->urlGenerator->generate($category$this->salesChannel));
    }

    public static function dataProviderLinkTypes(): array
    {
        return [
            [CategoryDefinition::LINK_TYPE_PRODUCT, 'frontend.detail.page'],
            [CategoryDefinition::LINK_TYPE_CATEGORY, 'frontend.navigation.page'],
            [
return [
            'id' => $category->getId(),
            'name' => $category->getName(),
            'metaKeywords' => $category->getMetaKeywords(),
            'metaDescription' => $category->getMetaDescription(),
            'cmsHeadline' => $category->getCmsHeadline(),
            'cmsText' => $category->getCmsText(),
            'active' => true,
            'template' => $category->getTemplate(),
            'blog' => $category->isBlog(),
            'path' => $path,
            'external' => $category->getExternalLink(),
            'externalTarget' => $category->getExternalTarget(),
            'hideFilter' => !$category->displayFacets(),
            'hideTop' => !$category->displayInNavigation(),
            'hidetop' => !$category->displayInNavigation(),
            'attribute' => $attribute,
            'media' => $media,
            'description' => $category->getName(),
            'link' => $category->getExternalLink() ?: $url . $category->getId(),
            'flag' => false,
            'subcategories' => [],
            'childrenCount' => $childrenCount,
        ];

        $converter = $this->get(LegacyStructConverter::class);
        $eventManager = $this->get('events');

        return array_map(function DCategory $category) use ($converter$eventManager) {
            $convertedCategory = $converter->convertCategoryStruct($category);

            $convertedCategory['flag'] = false;
            if ($category->getMedia()) {
                $convertedCategory['media']['path'] = $category->getMedia()->getFile();
            }
            if (!empty($category->getExternalLink())) {
                $convertedCategory['link'] = $category->getExternalLink();
            }

            return $eventManager->filter('Shopware_Plugins_AdvancedMenu_ConvertCategory', $convertedCategory[
                'category' => $category,
            ]);
        }$categories);
    }
}
'position' => $category->getPosition(),
            'metaTitle' => $category->getMetaTitle(),
            'metaKeywords' => $category->getMetaKeywords(),
            'metaDescription' => $category->getMetaDescription(),
            'cmsHeadline' => $category->getCmsHeadline(),
            'cmsText' => $category->getCmsText(),
            'active' => true,
            'template' => $category->getTemplate(),
            'productBoxLayout' => $this->getProductBoxLayout($category),
            'blog' => $category->isBlog(),
            'path' => $categoryPath,
            'external' => $category->getExternalLink(),
            'externalTarget' => $category->getExternalTarget(),
            'hideFilter' => !$category->displayFacets(),
            'hideTop' => !$category->displayInNavigation(),
            'changed' => null,
            'added' => null,
            'attribute' => $attribute,
            'attributes' => $category->getAttributes(),
            'media' => $media,
            'mediaId' => $category->getMedia() ? $category->getMedia()->getId() : null,
            'link' => $this->getCategoryLink($category),
            'streamId' => $productStream ? $productStream['id'] : null,
            
Home | Imprint | This part of the site doesn't use cookies.