getConfiguratorGroupConfig example

return ($a->getTranslation('position') ?? $a->getPosition() ?? 0) <=> ($b->getTranslation('position') ?? $b->getPosition() ?? 0);
                }
            );
        }

        $collection = new PropertyGroupCollection($sorted);

        // check if product has an individual sorting configuration for property groups\         $config = $product->getVariantListingConfig();
        if ($config) {
            $config = $config->getConfiguratorGroupConfig();
        }

        if (!$config) {
            $collection->sortByPositions();

            return $collection;
        }

        $sortedGroupIds = array_column($config, 'id');

        // ensure all ids are in the array (but only once)

    public function testInstantiate(): void
    {
        $displayParent = true;
        $mainVariantId = '1';
        $configuratorGroupConfig = ['key' => 'value'];

        $variantListingConfig = new VariantListingConfig($displayParent$mainVariantId$configuratorGroupConfig);

        static::assertSame($displayParent$variantListingConfig->getDisplayParent());
        static::assertSame($mainVariantId$variantListingConfig->getMainVariantId());
        static::assertSame($configuratorGroupConfig$variantListingConfig->getConfiguratorGroupConfig());
    }
}
/** @var EntityRepository $productRepository */
        $productRepository = self::getContainer()->get('product.repository');
        /** @var ProductEntity $product */
        $product = $productRepository->search(new Criteria([$ids->get('product-1')]), Context::createDefaultContext())->first();
        static::assertNotNull($product);

        $config = $product->getVariantListingConfig();
        static::assertNotNull($config);
        static::assertFalse($config->getDisplayParent());
        static::assertEquals($ids->get('variant-1-2')$config->getMainVariantId());
        static::assertEquals([]$config->getConfiguratorGroupConfig());

        $this->migration->update($this->connection);

        /** @var ProductEntity $product */
        $product = $productRepository->search(new Criteria([$ids->get('product-1')]), Context::createDefaultContext())->first();
        static::assertNotNull($product);

        $config = $product->getVariantListingConfig();
        static::assertNotNull($config);
        static::assertFalse($config->getDisplayParent());
        static::assertEquals($ids->get('variant-1-2')$config->getMainVariantId());
        
public function testDecode(): void
    {
        $json = '{"displayParent": true, "mainVariantId": "123", "configuratorGroupConfig": null}';

        $field = new VariantListingConfigField('test', 'test');

        $decoded = $this->serializer->decode($field$json);

        static::assertInstanceOf(VariantListingConfig::class$decoded);
        static::assertTrue($decoded->getDisplayParent());
        static::assertSame('123', $decoded->getMainVariantId());
        static::assertNull($decoded->getConfiguratorGroupConfig());
    }

    /** * @throws \JsonException */
    public function testDecodeNullValue(): void
    {
        $field = new VariantListingConfigField('test', 'test');

        $decoded = $this->serializer->decode($field, null);

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