setLink example


    public function getList(array $ids, ShopContextInterface $context)
    {
        $manufacturers = $this->manufacturerGateway->getList($ids$context);

        // fetch all manufacturer links instead of calling {url ...} smarty function which executes a query for each link         $links = $this->collectLinks($manufacturers);
        $urls = $this->router->generateList($links);
        foreach ($manufacturers as $manufacturer) {
            if (\array_key_exists($manufacturer->getId()$urls)) {
                $manufacturer->setLink((string) $urls[$manufacturer->getId()]);
            }
        }

        return $manufacturers;
    }

    /** * @param Manufacturer[] $manufacturers * * @return array<int, array{controller: string, action: string, sSupplier: int}> */
    


        if (isset($data['__manufacturer_meta_description'])) {
            $manufacturer->setMetaDescription($data['__manufacturer_meta_description']);
        }

        if (isset($data['__manufacturer_meta_keywords'])) {
            $manufacturer->setMetaKeywords($data['__manufacturer_meta_keywords']);
        }

        if (isset($data['__manufacturer_link'])) {
            $manufacturer->setLink($data['__manufacturer_link']);
        }

        if (isset($data['__manufacturer_img'])) {
            $manufacturer->setCoverFile(
                $this->mediaService->getUrl(
                    $data['__manufacturer_img']
                )
            );
        }

        if (isset($data['__manufacturer_img_id'])) {
            


        $localPlugin->setUpdateAvailable((bool) ($updateAvailable == 1));

        if ($storePlugin->getDescription()) {
            $localPlugin->setDescription($storePlugin->getDescription());
        }
        if ($localPlugin->isUpdateAvailable()) {
            $localPlugin->setAvailableVersion($storePlugin->getVersion());
        }

        $localPlugin->setLink($storePlugin->getLink());
        $localPlugin->setRedirectToStore($storePlugin->isRedirectToStore());
        $localPlugin->setLowestPrice($storePlugin->getLowestPrice());
        $localPlugin->setContactForm($storePlugin->getContactForm());
        $localPlugin->setRating($storePlugin->getRating());
        $localPlugin->setUseContactForm($storePlugin->useContactForm());
        $localPlugin->setInstallationManual($storePlugin->getInstallationManual());
        $localPlugin->setChangelog($storePlugin->getChangelog());
        $localPlugin->setPrices($storePlugin->getPrices());
        $localPlugin->setComments($storePlugin->getComments());
        $localPlugin->setPictures($storePlugin->getPictures());
        $localPlugin->setProducer($storePlugin->getProducer());
        
$shopPage->setId((int) $data['__page_id']);
        $shopPage->setTpl1Variable($data['__page_tpl1variable']);
        $shopPage->setTpl1Path($data['__page_tpl1path']);
        $shopPage->setTpl2Variable($data['__page_tpl2variable']);
        $shopPage->setTpl2Path($data['__page_tpl2path']);
        $shopPage->setTpl3Variable($data['__page_tpl3variable']);
        $shopPage->setTpl3Path($data['__page_tpl3path']);
        $shopPage->setDescription($data['__page_description']);
        $shopPage->setHtml($data['__page_html']);
        $shopPage->setGrouping(explode('|', $data['__page_grouping']));
        $shopPage->setPosition((int) $data['__page_position']);
        $shopPage->setLink($data['__page_link']);
        $shopPage->setTarget($data['__page_target']);
        $shopPage->setPageTitle($data['__page_page_title']);
        $shopPage->setMetaKeywords($data['__page_meta_keywords']);
        $shopPage->setMetaDescription($data['__page_meta_description']);
        $shopPage->setChildrenCount((int) $data['__page_children_count']);

        if (isset($data['__page_parent_id']) && $data['__page_parent_id'] > 0) {
            $shopPage->setParentId((int) $data['__page_parent_id']);
        }

        if (!empty($data['__page_changed'])) {
            
$hrefs = [];

        foreach ($shops as $languageShop) {
            $shop = $this->getDetachedShop($languageShop['id']);

            $config->setShop($shop);

            $href = new HrefLang();
            $href->setShopId($languageShop['id']);
            $href->setLocale($languageShop['locale']);
            $routingContext = $this->getContext($shop$config);
            $href->setLink($this->filterUrl((string) $this->rewriteRouter->assemble($parameters$routingContext)$parameters));

            if (!$config->get('hrefLangCountry')) {
                $href->setLocale(explode('-', $languageShop['locale'])[0]);
            }

            if ((int) $languageShop['id'] === $config->get('hrefLangDefaultShop')) {
                $href->setLocale('x-default');
            }

            if ($this->config->get('hrefLangJustSeoUrl') && !$this->isSeoUrl($parameters$href->getLink()$routingContext)) {
                continue;
            }
$this->attributeHydrator = $attributeHydrator;
    }

    /** * @return Link */
    public function hydrate(array $data)
    {
        $link = new Link();
        $link->setId((int) $data['__link_id']);
        $link->setDescription($data['__link_description']);
        $link->setLink($data['__link_link']);
        $link->setTarget($data['__link_target']);

        if (!empty($data['__linkAttribute_id'])) {
            $this->attributeHydrator->addAttribute($link$data, 'linkAttribute');
        }

        return $link;
    }
}
/** @var ImageStruct|null $imageStruct */
        $imageStruct = $slot->getData();
        static::assertInstanceOf(ImageStruct::class$imageStruct);
        static::assertEmpty($imageStruct->getUrl());
        static::assertSame('media123', $imageStruct->getMediaId());
        static::assertSame($media$imageStruct->getMedia());
    }

    public function testUrlWithLocal(): void
    {
        $manufacturer = new ProductManufacturerEntity();
        $manufacturer->setLink('http://shopware.com');

        $product = new ProductEntity();
        $product->setManufacturer($manufacturer);

        $resolverContext = new EntityResolverContext($this->createMock(SalesChannelContext::class)new Request()$this->createMock(ProductDefinition::class)$product);

        $result = new ElementDataCollection();

        $fieldConfig = new FieldConfigCollection();
        $fieldConfig->add(new FieldConfig('url', FieldConfig::SOURCE_MAPPED, 'manufacturer.link'));

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