setFields example

static::assertEquals('plugin-123', $entity->getPluginId());

        $fields = [
            [
                'name' => 'field1',
            ],
            [
                'name' => 'field2',
            ],
        ];

        $entity->setFields($fields);
        static::assertEquals($fields$entity->getFields());

        $flags = [];

        $entity->setFlags($flags);
        static::assertEquals($flags$entity->getFlags());

        $entity->setCustomFieldsAware(true);
        static::assertTrue($entity->getCustomFieldsAware());

        $entity->setLabelProperty('name');
        
private $productSortingRepository;

    protected function setUp(): void
    {
        parent::setUp();
        $this->productSortingRepository = $this->getContainer()->get('product_sorting.repository');
    }

    public function testProductSortingFieldPriority(): void
    {
        $productSortingEntity = new ProductSortingEntity();
        $productSortingEntity->setFields(
            [
                ['field' => 'product.name', 'order' => 'asc', 'priority' => 1, 'naturalSorting' => 1],
                ['field' => 'product.cheapestPrice', 'order' => 'asc', 'priority' => 1000, 'naturalSorting' => 1],
            ]
        );

        /** @var FieldSorting[] $sortings */
        $sortings = $productSortingEntity->createDalSorting();

        static::assertCount(2, $sortings);
        static::assertEquals('product.cheapestPrice', $sortings[0]->getField());
        
$class->setSeoRobots($type['seoRobots']);
        }

        $fieldSets = [];
        $fields = [];
        foreach ($type['fieldSets'] as $fieldSet) {
            $fieldSet = $this->createFieldset($fieldSet);
            $fieldSets[] = $fieldSet;
            $fields = array_merge($fields$fieldSet->getFields());
        }

        $class->setFields($fields);
        $class->setFieldSets($fieldSets);

        return $class;
    }

    public function createFieldset(array $fieldset): Fieldset
    {
        $class = new Fieldset();

        if (isset($fieldset['label'])) {
            $class->setLabel($fieldset['label']);
        }


    private function enrichCmsAware(CustomEntityXmlSchema $customEntityXmlSchema): CustomEntityXmlSchema
    {
        foreach ($customEntityXmlSchema->getEntities()?->getEntities() ?? [] as $entity) {
            if ($entity->isCmsAware() !== true) {
                continue;
            }

            $fields = $entity->getFields();
            $fields = array_merge($fields, CmsAwareFields::getCmsAwareFields());
            $entity->setFields($fields);

            $flags = $entity->getFlags();
            $flags = [...$flags, ...['cms-aware' => ['name' => $entity->getName()]]];
            $entity->setFlags($flags);
        }

        return $customEntityXmlSchema;
    }

    private function enrichAdminUi(CustomEntityXmlSchema $customEntityXmlSchema, AdminUiXmlSchema $adminUiXmlSchema): CustomEntityXmlSchema
    {
        
Home | Imprint | This part of the site doesn't use cookies.