CategoryBuilder example



        $product = new ProductBuilder($ids, Uuid::randomHex(), 100);
        $product->price(100);
        $product->customField('custom_field_media_product', $ids->get('media-1'));
        $product->customField('custom_field_media_select_product', $ids->get('media-2'));
        $product->customField('custom_field_media_multi_select_product', [$ids->get('media-2')$ids->get('media-3')$ids->get('media-4')]);
        $products = [$product->build()];

        $this->getContainer()->get('product.repository')->create($products, Context::createDefaultContext());

        $category = new CategoryBuilder($ids, 'Category');
        $category->customField('custom_field_media_category', $ids->get('media-5'));
        $category->customField('custom_field_media_select_category', $ids->get('media-6'));
        $category->customField('custom_field_media_multi_select_category', [$ids->get('media-7')$ids->get('media-8')$ids->get('media-9')]);

        $categories = [$category->build()];

        $this->getContainer()->get('category.repository')->create($categories, Context::createDefaultContext());

        return array_values($mediaIds);
    }

    

                    'url' => ['value' => null, 'source' => 'static'],
                    'newTab' => ['value' => false, 'source' => 'static'],
                    'minHeight' => ['source' => 'static', 'value' => '300px'],
                    'displayMode' => ['value' => 'standard', 'source' => 'static'],
                    'verticalAlign' => ['value' => null, 'source' => 'static'],
                ],
            )
            ->build();

        // create a category with image slider, and image override         $category = (new CategoryBuilder($ids, 'category-1'))
            ->layout('my-category-layout')
            ->slot(
                'slot-1',
                [
                    'sliderItems' => [
                        'source' => 'static',
                        'value' => array_map(fn (string $id) => ['mediaId' => $id]array_values($ids->getList(['media-13', 'media-14']))),
                    ],
                    'speed' => ['source' => 'static', 'value' => 300],
                    'autoSlide' => ['source' => 'static', 'value' => false],
                    'minHeight' => ['source' => 'static', 'value' => '300px'],
                    
Home | Imprint | This part of the site doesn't use cookies.