getManufacturerId example



        $payload = [
            'isCloseout' => $product->getIsCloseout(),
            'customFields' => $product->getCustomFields(),
            'createdAt' => $product->getCreatedAt() ? $product->getCreatedAt()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'releaseDate' => $product->getReleaseDate() ? $product->getReleaseDate()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'isNew' => $product->isNew(),
            'markAsTopseller' => $product->getMarkAsTopseller(),
            'purchasePrices' => $purchasePrices ? json_encode($purchasePrices, \JSON_THROW_ON_ERROR) : null,
            'productNumber' => $product->getProductNumber(),
            'manufacturerId' => $product->getManufacturerId(),
            'taxId' => $product->getTaxId(),
            'tagIds' => $product->getTagIds(),
            'categoryIds' => $product->getCategoryTree(),
            'propertyIds' => $product->getPropertyIds(),
            'optionIds' => $product->getOptionIds(),
            'options' => $product->getVariation(),
            'streamIds' => $product->getStreamIds(),
            'parentId' => $product->getParentId(),
            'stock' => $product->getStock(),
        ];

        
public function filterByTaxId(string $id): self
    {
        return $this->filter(fn (ProductEntity $product) => $product->getTaxId() === $id);
    }

    /** * @return list<string> */
    public function getManufacturerIds(): array
    {
        /** @var list<string> $ids */
        $ids = $this->fmap(fn (ProductEntity $product) => $product->getManufacturerId());

        return $ids;
    }

    public function filterByManufacturerId(string $id): self
    {
        return $this->filter(fn (ProductEntity $product) => $product->getManufacturerId() === $id);
    }

    /** * @return list<string> */
$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);
        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]);
        
$context = Context::createDefaultContext();
        $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)]
        );

        
$this->import($context, ProductDefinition::ENTITY_NAME, '/fixtures/products_with_own_identifier.csv', 'products.csv');

        $criteria = new Criteria([$productIds[0]]);
        $criteria->addAssociation('categories');

        $product = $this->productRepository->search($criteria$context)->first();

        static::assertInstanceOf(ProductEntity::class$product);
        static::assertNotSame($name$product->getName());
        static::assertSame(Uuid::fromStringToHex('tax19')$product->getTaxId());
        static::assertSame(Uuid::fromStringToHex('manufacturer1')$product->getManufacturerId());

        static::assertInstanceOf(CategoryCollection::class$categories = $product->getCategories());
        static::assertCount(3, $categories);
        static::assertTrue($categories->has($category1Id));
        static::assertTrue($categories->has($category2Id));
        static::assertTrue($categories->has($category3Id));
    }

    public function testProductsWithCategoryPaths(): void
    {
        $context = Context::createDefaultContext();
        
Home | Imprint | This part of the site doesn't use cookies.