category example

$products = [
            (new ProductBuilder($ids, 'john'))
                ->tag('tag1')
                ->tag('tag2')
                ->tag('tag3')
                ->name('John')
                ->price(100)
                ->build(),
            (new ProductBuilder($ids, 'john.doe'))->name('John Doe')->price(100)->build(),
            (new ProductBuilder($ids, 'doe'))->name('Doe')
                ->category('cat1')
                ->category('cat2')
                ->category('cat3')
                ->tag('tag1')
                ->tag('tag2')
                ->tag('tag3')
                ->price(100)->build(),
        ];

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

        

    }

    public function testTemplateWithMultipleAssociations(): void
    {
        $ids = new IdsCollection();

        $product = (new ProductBuilder($ids, 'product'))
            ->price(100)
            ->visibility($this->salesChannelId)
            ->manufacturer('shopware')
            ->category('test category');

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

        $productIds = $ids->getList(['product']);
        $template = '{% if product.categories %}{% for var in product.categories %}{{ var.translated.name }}-{% endfor %}{% endif %}{{ product.manufacturer.translated.name }}-{{ product.translated.name|lower }}';
        $route = $this->seoUrlRouteRegistry->findByRouteName(TestProductSeoUrlRoute::ROUTE_NAME);
        static::assertInstanceOf(SeoUrlRouteInterface::class$route);

        $result = $this->seoUrlGenerator->generate($productIds$template$route, Context::createDefaultContext()$this->salesChannelContext->getSalesChannel());

        

        $this->categories[] = ['id' => $this->ids->create($key), 'name' => $key];

        return $this;
    }

    /** * @param array<string> $keys */
    public function categories(array $keys): self
    {
        array_map($this->category(...)$keys);

        return $this;
    }

    /** * @param mixed $value */
    public function customField(string $key$value): self
    {
        $this->customFields[$key] = $value;

        

        }
    }

    private function createData(TestDataCollection $ids): void
    {
        $products = [
            (new ProductBuilder($ids, 'product-1'))
                ->name('Aerodynamic Leather DotCondom')
                ->tax('t1')
                ->price(50, 50)
                ->category('Shoes')
                ->build(),
            (new ProductBuilder($ids, 'product-2'))
                ->name('Aerodynamic Leather Portaline')
                ->price(50, 50)
                ->build(),
            (new ProductBuilder($ids, 'product-3'))
                ->name('Aerodynamic Leather Wordlobster')
                ->price(50, 50)
                ->add('customSearchKeywords', ['Activity'])
                ->build(),
            (new ProductBuilder($ids, 'product-4'))
                


    private function createProduct(): void
    {
        $products = [
            (new ProductBuilder($this->ids, 'product1-with-category', 10))
                ->categories(['category1', 'category2'])
                ->visibility()
                ->price(10)
                ->build(),
            (new ProductBuilder($this->ids, 'product2-with-category', 12))
                ->category('category2')
                ->visibility()
                ->price(20)
                ->build(),
            (new ProductBuilder($this->ids, 'product1-without-category', 14))
                ->visibility()
                ->price(30)
                ->build(),
            (new ProductBuilder($this->ids, 'product2-without-category', 16))
                ->visibility()
                ->price(40)
                ->build(),
        ];
function DIdsCollection $ids, SalesChannelContext $context): void {
            },
            1,
        ];

        yield 'Test assign a new product to the category as listing product' => [
            $ids,
            function DIdsCollection $ids, SalesChannelContext $context, ContainerInterface $container): void {
                $product = (new ProductBuilder($ids, 'test-assign'))
                    ->price(100)
                    ->visibility()
                    ->category('navigation')
                    ->build();

                $container->get('product.repository')
                    ->create([$product]$context->getContext());
            },
            2,
        ];

        yield 'Test update a product which is assigned as listing product' => [
            $ids,
            function DIdsCollection $ids, SalesChannelContext $context, ContainerInterface $container): void {
                
static::assertInstanceOf(WriteConstraintViolationException::class$first);
        static::assertStringStartsWith('/manufacturers/1/translations', $first->getPath());
    }

    public function testDeleteWithWildCards(): void
    {
        $ids = new IdsCollection();

        $products = [
            (new ProductBuilder($ids, 'p1'))
                ->price(100)
                ->category('c1')
                ->category('c2')
                ->build(),
            (new ProductBuilder($ids, 'p2'))
                ->price(100)
                ->category('c1')
                ->category('c3')
                ->build(),
            (new ProductBuilder($ids, 'p3'))
                ->price(100)
                ->category('c4')
                ->build(),
        ];
static::assertIsArray($variantBProperties);
        sort($variantBProperties);

        static::assertEquals($productProperties$variantAProperties);
        static::assertEquals($productProperties$variantBProperties);
    }

    public function testInheritanceUpdateOnDeleteRelation(): void
    {
        $ids = new IdsCollection();

        $product = (new ProductBuilder($ids, 'x1'))->price(100)->category('c1')->build();
        $this->getContainer()->get('product.repository')->upsert([$product], Context::createDefaultContext());

        $event = $this->getContainer()->get('category.repository')->delete([['id' => $ids->get('c1')]], Context::createDefaultContext());

        $expected = [
            'category.deleted' => [$ids->get('c1')],
            'product_category.deleted' => [['productId' => $ids->get('x1'), 'categoryId' => $ids->get('c1')]],
            'product_category_tree.deleted' => [['productId' => $ids->get('x1'), 'categoryId' => $ids->get('c1')]],
            'product.written' => [$ids->get('x1')],
        ];

        


    public function testCategoryNoId(): void
    {
        if (Feature::isActive('v6.6.0.0')) {
            $this->expectException(RoutingException::class);
        } else {
            $this->expectException(MissingRequestParameterException::class);
        }
        $this->expectExceptionMessage('Parameter "navigationId" is missing.');

        $this->controller->category(null, new Request()$this->createMock(SalesChannelContext::class));
    }

    public function testCategoryReturn(): void
    {
        $categoryEntity = new CategoryEntity();
        $categoryEntity->setCmsPage(new CmsPageEntity());
        $categoryRouteResponse = new CategoryRouteResponse($categoryEntity);
        $this->categoryRouteMock->method('load')->willReturn($categoryRouteResponse);

        $ids = new IdsCollection();

        
static::assertInstanceOf(ParentAssociationCanNotBeFetched::class$exception);
    }

    public function testLoadToOneWithToMany(): void
    {
        $ids = new IdsCollection();

        $products = [
            (new ProductBuilder($ids, 'product-1'))
                ->price(100)
                ->category('test-1')
                ->build(),
            (new ProductBuilder($ids, 'product-2'))
                ->price(100)
                ->category('test-2')
                ->build(),
        ];

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

        $criteria = new Criteria();
        $criteria->addAssociation('translations.language.categoryTranslations');

        
protected function setUp(): void
    {
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->entityLoadedEventFactory = $this->getContainer()->get(EntityLoadedEventFactory::class);
        $this->ids = new IdsCollection();
    }

    public function testCreate(): void
    {
        $builder = (new ProductBuilder($this->ids, 'p1'))
            ->price(10)
            ->category('c1')
            ->manufacturer('m1')
            ->prices('r1', 5);

        $this->productRepository->create([$builder->build()], Context::createDefaultContext());

        $criteria = new Criteria();
        $criteria->addAssociations([
            'manufacturer',
            'prices',
            'categories',
        ]);

        
namespace Symfony\Component\Notifier\Bridge\ContactEveryone\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\ContactEveryone\ContactEveryoneOptions;

class ContactEveryoneOptionsTest extends TestCase
{
    public function testContactEveryoneOptions()
    {
        $contactEveryoneOptions = (new ContactEveryoneOptions())
            ->category('test_category')
            ->diffusionName('test_diffusion_name');

        self::assertSame([
            'category' => 'test_category',
            'diffusionname' => 'test_diffusion_name',
        ]$contactEveryoneOptions->toArray());
    }
}
$newImplementation = $this->getContainer()->get(EsProductDefinition::class);

        ReflectionHelper::getProperty(EsProductDefinition::class, 'customFieldsTypes')->setValue(
            $newImplementation,
            $customMapping
        );

        $products = [
            (new ProductBuilder($this->ids, 'product-1'))
                ->name('Silk')
                ->category('navi')
                ->customField('testField', 'Silk')
                ->visibility(TestDefaults::SALES_CHANNEL)
                ->tax('t1')
                ->manufacturer('m1')
                ->price(50, 50, 'default', 150, 150)
                ->releaseDate('2019-01-01 10:11:00')
                ->purchasePrice(0)
                ->stock(2)
                ->createdAt('2019-01-01 10:11:00')
                ->category('c1')
                ->category('c2')
                

        $ids = new IdsCollection();

        $products = [
            (new ProductBuilder($ids, 'product-1', 10, 'tax'))
                ->price(15, 10)
                ->manufacturer('manufacturer-1')
                ->property('red', 'color')
                ->property('yellow', 'color')
                ->property('XL', 'size')
                ->property('L', 'size')
                ->category('category-1')
                ->category('category-2')
                ->prices('rule-1', 100)
                ->prices('rule-2', 150)
                ->build(),

            (new ProductBuilder($ids, 'product-1-variant', 10, 'tax'))
                ->parent('product-1')
                ->build(),

            (new ProductBuilder($ids, 'product-2', 3, 'tax'))
                ->price(15, 10)
                
->visibility($this->ids->get('sales-channel'))
                    ->build(),
        ];

        foreach ($productsNames as $name => $number) {
            $products[] = (new ProductBuilder($this->ids, $number))
                ->name($name)
                ->stock(1)
                ->price(19.99, 10)
                ->manufacturer('shopware AG')
                ->tax('15', 15)
                ->category('random cat')
                ->visibility($this->ids->get('sales-channel'))
                ->build();
        }

        for ($i = 1; $i <= 15; ++$i) {
            $products[] = (new ProductBuilder($this->ids, 'product' . $i))
                ->name('Test-Product')
                ->manufacturer('test-' . $i)
                ->active(true)
                ->price(15, 10)
                ->tax('test', 15)
                
Home | Imprint | This part of the site doesn't use cookies.