getConfiguratorSetting example

$productId = $this->insertDuplicateData();

        $criteria = (new Criteria())->addFilter(new EqualsFilter('product.parentId', $productId));
        $salesChannelProduct = $this->salesChannelProductRepository->search($criteria$this->context)->first();

        // property group with highest value UUID should be returned         $propertyGroups = $this->loader->load($salesChannelProduct$this->context);
        static::assertEquals(1, $propertyGroups->count());
        $propertyGroup = $propertyGroups->first();
        static::assertEquals(1, $propertyGroup->getOptions()->count());
        $option = $propertyGroup->getOptions()->first();
        static::assertSame('00000000000000000000000000000999', $option->getConfiguratorSetting()->getId());

        // remove duplicates, as the migration would         $this->removeDuplicates();

        // property group with highest value UUID should be returned         $propertyGroups = $this->loader->load($salesChannelProduct$this->context);
        static::assertEquals(1, $propertyGroups->count());
        $propertyGroup = $propertyGroups->first();
        static::assertEquals(1, $propertyGroup->getOptions()->count());
        $option = $propertyGroup->getOptions()->first();
        static::assertSame('00000000000000000000000000000999', $option->getConfiguratorSetting()->getId());

        
$sorted[$group->getId()] = $group;
        }

        /** @var PropertyGroupEntity $group */
        foreach ($sorted as $group) {
            $options = $group->getOptions();
            if ($options === null) {
                continue;
            }
            $options->sort(
                static function DPropertyGroupOptionEntity $a, PropertyGroupOptionEntity $b) use ($group) {
                    $configuratorSettingA = $a->getConfiguratorSetting();
                    $configuratorSettingB = $b->getConfiguratorSetting();

                    if ($configuratorSettingA !== null && $configuratorSettingB !== null
                        && $configuratorSettingA->getPosition() !== $configuratorSettingB->getPosition()) {
                        return $configuratorSettingA->getPosition() <=> $configuratorSettingB->getPosition();
                    }

                    if ($group->getSortingType() === PropertyGroupDefinition::SORTING_TYPE_ALPHANUMERIC) {
                        return strnatcmp((string) $a->getTranslation('name')(string) $b->getTranslation('name'));
                    }

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