getPropertyIds example

public function testPropertyIndexing(): void
    {
        $data = new TestDataCollection();

        $this->createProduct($data);

        /** @var ProductEntity|null $product */
        $product = $this->productRepository->search(new Criteria([$data->get('product')]), Context::createDefaultContext())->first();

        static::assertInstanceOf(ProductEntity::class$product);
        $propertyIds = $product->getPropertyIds();
        static::assertIsArray($propertyIds);
        static::assertIsArray($propertyIds);
        static::assertContains($data->get('red')$propertyIds);
        static::assertNotContains($data->create('yellow')$propertyIds);
        static::assertContains($data->get('green')$propertyIds);

        $this->productPropertyRepository->delete(
            [['productId' => $data->get('product'), 'optionId' => $data->get('red')]],
            Context::createDefaultContext()
        );

        


        $this->repository->upsert([$data]$context);

        /** @var ProductCollection $variants */
        $variants = $this->repository->search(new Criteria([$variantB$variantA])$context)->getEntities();
        $product = $this->repository->search(new Criteria([$productId])$context)->first();

        static::assertCount(2, $variants);
        static::assertInstanceOf(ProductEntity::class$product);

        $productProperties = $product->getPropertyIds();
        static::assertTrue($variants->has($variantA));
        $variantAProperties = $variants->get($variantA)->getPropertyIds();
        static::assertTrue($variants->has($variantB));
        $variantBProperties = $variants->get($variantB)->getPropertyIds();

        static::assertIsArray($productProperties);
        sort($productProperties);
        static::assertIsArray($variantAProperties);
        sort($variantAProperties);
        static::assertIsArray($variantBProperties);
        sort($variantBProperties);

        
$aggregations->remove('configurators');
        $aggregations->remove('options');

        $aggregations->add(new EntityResult('properties', $grouped));
    }

    /** * @param array<string>|null $groupIds */
    private function getPropertyFilter(Request $request, ?array $groupIds = null): Filter
    {
        $ids = $this->getPropertyIds($request);

        $propertyAggregation = new TermsAggregation('properties', 'product.properties.id');

        $optionAggregation = new TermsAggregation('options', 'product.options.id');

        if ($groupIds) {
            $propertyAggregation = new FilterAggregation(
                'properties-filter',
                $propertyAggregation,
                [new EqualsAnyFilter('product.properties.groupId', $groupIds)]
            );

            
'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(),
        ];

        $lineItem->replacePayload($payload['purchasePrices' => true]);
    }

    private function getPriceDefinition(SalesChannelProductEntity $product, SalesChannelContext $context, int $quantity): QuantityPriceDefinition
    {
Home | Imprint | This part of the site doesn't use cookies.