getManufacturer example

$salesChannel = $this->salesChannelRepository->search($criteria1$context)->get($salesChannelId);

        static::assertInstanceOf(SalesChannelEntity::class$salesChannel);
        static::assertEquals($name$salesChannel->getName());
        static::assertEquals($accessKey$salesChannel->getAccessKey());

        static::assertInstanceOf(SalesChannelTypeEntity::class$salesChannel->getType());
        static::assertEquals($cover$salesChannel->getType()->getCoverUrl());
        static::assertEquals($icon$salesChannel->getType()->getIconName());
        static::assertEquals($screenshots$salesChannel->getType()->getScreenshotUrls());
        static::assertEquals($typeName$salesChannel->getType()->getName());
        static::assertEquals($manufacturer$salesChannel->getType()->getManufacturer());
        static::assertEquals($description$salesChannel->getType()->getDescription());
        static::assertEquals($descriptionLong$salesChannel->getType()->getDescriptionLong());

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('currency.salesChannels.id', $salesChannelId));
        $currency = $this->currencyRepository->search($criteria$context);
        static::assertEquals(1, $currency->count());

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('language.salesChannels.id', $salesChannelId));
        $language = $this->languageRepository->search($criteria$context);
        
$product->setCheapestPriceRule($cheapestPrices[$number]);
            }

            if (isset($voteAverages[$number])) {
                $product->setVoteAverage($voteAverages[$number]);
            }

            if (isset($categories[$number])) {
                $product->setCategories($categories[$number]);
            }

            if ($product->getManufacturer() && isset($manufacturerCovers[$product->getManufacturer()->getCoverId()])) {
                $product->getManufacturer()->setCoverMedia($manufacturerCovers[$product->getManufacturer()->getCoverId()]);
            }

            $product->addAttribute('marketing', $this->marketingService->getProductAttribute($product));

            $this->priceCalculationService->calculateProduct($product$context);

            if (!$this->isProductValid($product$context)) {
                continue;
            }

            

                SalesChannelRepositoryFacadeHookFactory::class,
            ]
        );

        $this->getContainer()->get(ScriptExecutor::class)->execute($hook);

        static::assertTrue($page->hasExtension('myProduct'));
        $product = $page->getExtension('myProduct');
        static::assertInstanceOf(SalesChannelProductEntity::class$product);
        static::assertEquals($this->ids->get('p1')$product->getId());
        static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());

        $manufacturer = $page->getExtension('myManufacturer');
        static::assertInstanceOf(ProductManufacturerEntity::class$manufacturer);
        static::assertEquals($this->ids->get('m1')$manufacturer->getId());
    }

    public function testSearchIdsIntegration(): void
    {
        $this->ids = new IdsCollection();
        $this->createProducts();

        


            if (strpos($temp['link'], 'http') === false) {
                $temp['link'] = 'http://' . $link->getLink();
            }

            $data['sLinks'][] = $temp;
        }

        $data['sLinks'][] = [
            'supplierSearch' => true,
            'description' => $product->getManufacturer()->getName(),
            'target' => '_parent',
            'link' => $this->getSupplierListingLink($product->getManufacturer()),
        ];

        $data['sRelatedArticles'] = [];
        foreach ($product->getRelatedProducts() as $relatedProduct) {
            $data['sRelatedArticles'][] = $this->convertListProductStruct($relatedProduct);
        }

        $data['sSimilarArticles'] = [];
        foreach ($product->getSimilarProducts() as $similarProduct) {
            
public function getTaxes(): TaxCollection
    {
        return new TaxCollection(
            $this->fmap(fn (ProductEntity $product) => $product->getTax())
        );
    }

    public function getManufacturers(): ProductManufacturerCollection
    {
        return new ProductManufacturerCollection(
            $this->fmap(fn (ProductEntity $product) => $product->getManufacturer())
        );
    }

    public function getUnits(): UnitCollection
    {
        return new UnitCollection(
            $this->fmap(fn (ProductEntity $product) => $product->getUnit())
        );
    }

    /** * @return list<string> */
public function assignProductData(ListProduct $listProduct, ListProduct $product)
    {
        trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be removed with 5.7. Will be removed without replacement.', __CLASS__, __METHOD__), E_USER_DEPRECATED);

        $product->setShippingFree($listProduct->isShippingFree());
        $product->setMainVariantId($listProduct->getMainVariantId());
        $product->setAllowsNotification($listProduct->allowsNotification());
        $product->setHighlight($listProduct->highlight());
        $product->setUnit($listProduct->getUnit());
        $product->setTax($listProduct->getTax());
        $product->setPrices($listProduct->getPrices());
        $product->setManufacturer($listProduct->getManufacturer());
        $product->setCover($listProduct->getCover());
        $product->setCheapestPrice($listProduct->getCheapestPrice());
        $product->setName($listProduct->getName());
        $product->setAdditional($listProduct->getAdditional());
        $product->setCloseouts($listProduct->isCloseouts());
        $product->setEan($listProduct->getEan());
        $product->setHeight($listProduct->getHeight());
        $product->setKeywords($listProduct->getKeywords());
        $product->setLength($listProduct->getLength());
        $product->setLongDescription($listProduct->getLongDescription());
        $product->setMinStock($listProduct->getMinStock());
        
$context->setConsiderInheritance(true);

        $criteria = new Criteria([$id]);
        $criteria->addAssociation('manufacturer');

        /** @var ProductEntity $product */
        $product = $this->getContainer()->get('product.repository')
            ->search($criteria$context)
            ->get($id);

        static::assertEquals($association$product->getManufacturerId());
        static::assertEquals($association$product->getManufacturer()->getId());
    }

    private function assertPriceInheritance(string $id, ?string $fk, ?string $association, bool $hasPrices = true): void
    {
        $connection = $this->getContainer()->get(Connection::class);

        $inheritance = $connection->fetchAssociative(
            'SELECT LOWER(HEX(prices)) as association FROM product WHERE id = :id',
            ['id' => Uuid::fromHexToBytes($id)]
        );

        
$result = new ElementDataCollection();

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('manufacturer-logo');

        $this->manufacturerLogoCmsElementResolver->enrich($slot$resolverContext$result);

        /** @var ManufacturerLogoStruct|null $manufacturerLogoStruct */
        $manufacturerLogoStruct = $slot->getData();
        static::assertInstanceOf(ManufacturerLogoStruct::class$manufacturerLogoStruct);
        static::assertNull($manufacturerLogoStruct->getManufacturer());
    }

    public function testEnrichEntityResolverContext(): void
    {
        $manufacturer = new ProductManufacturerEntity();
        $manufacturer->setId('manufacturer_01');
        $product = new SalesChannelProductEntity();
        $product->setId('product_01');
        $product->setManufacturer($manufacturer);
        $resolverContext = new EntityResolverContext($this->createMock(SalesChannelContext::class)new Request()$this->getContainer()->get(SalesChannelProductDefinition::class)$product);
        $result = new ElementDataCollection();

        
$this->repository->create($data$this->context);
        $ids = array_column($data, 'id');
        $criteria = new Criteria($ids);
        $criteria->addAssociation('manufacturer');

        $products = $this->repository->search($criteria$this->context);

        $product = $products->get($ids[0]);

        static::assertInstanceOf(ProductEntity::class$product);
        static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());
        static::assertSame('without id', $product->getManufacturer()->getName());

        $product = $products->get($ids[1]);
        static::assertInstanceOf(ProductEntity::class$product);
        static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());
        static::assertSame($manufacturerId$product->getManufacturerId());
        static::assertSame($manufacturerId$product->getManufacturer()->getId());
        static::assertSame('with id', $product->getManufacturer()->getName());

        $product = $products->get($ids[2]);
        static::assertInstanceOf(ProductEntity::class$product);
        
if ($mediaConfig !== null) {
            $media = $this->getMedia($slot$result$mediaConfig$resolverContext);
            if ($media !== null) {
                $manufacturerStruct->setMedia($media);
                $manufacturerStruct->setMediaId($media->getId());
            }
        }

        if ($resolverContext instanceof EntityResolverContext && $resolverContext->getDefinition() instanceof SalesChannelProductDefinition) {
            /** @var SalesChannelProductEntity $product */
            $product = $resolverContext->getEntity();
            $manufacturerStruct->setManufacturer($product->getManufacturer());
        }
    }

    private function getConfigUrl(FieldConfig $config, ResolverContext $resolverContext): ?string
    {
        if ($config->isStatic()) {
            return $config->getStringValue();
        }

        if (!$resolverContext instanceof EntityResolverContext) {
            return null;
        }

                RepositoryFacadeHookFactory::class,
            ]
        );

        $this->getContainer()->get(ScriptExecutor::class)->execute($hook);

        static::assertTrue($page->hasExtension('myProduct'));
        $product = $page->getExtension('myProduct');
        static::assertInstanceOf(ProductEntity::class$product);
        static::assertEquals($this->ids->get('p1')$product->getId());
        static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());

        $manufacturer = $page->getExtension('myManufacturer');
        static::assertInstanceOf(ProductManufacturerEntity::class$manufacturer);
        static::assertEquals($this->ids->get('m1')$manufacturer->getId());
    }

    public function testSearchIdsIntegration(): void
    {
        $this->ids = new IdsCollection();
        $this->createProducts();

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