manufacturer example

parent::tearDown();
    }

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

        $product = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->categories(['c1', 'c2'])
            ->visibility()
            ->manufacturer('m1');

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

        $criteria = new Criteria();
        $criteria->addFields(['productNumber', 'name', 'categories.name']);

        $values = $this->getContainer()
            ->get('product.repository')
            ->search($criteria, Context::createDefaultContext());

        

        $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',
        ]);

        
$this->getContainer()->get('product.repository')
            ->create([$product->build()]$live);

        // after having a simple product - create new version         $versionId = $this->productRepository->createVersion($ids->get('p1')$live);

        $version = $live->createWithVersionId($versionId);

        // now we want to create a manufacturer and update the product record at the same time         $update = (new ProductBuilder($ids, 'p1'))
            ->manufacturer('manufacturer');

        $this->productRepository->update([$update->build()]$version);

        // when the version is merged - the manufacturer should be created first         $this->getContainer()->get('product.repository')->merge($versionId$live);
    }

    private function getReviewCount(string $productId, string $versionId): int
    {
        return (int) $this->connection
            ->fetchOne(
                
                ],
                [
                    '1000', // productNumber                     'product', // part of name                     'test', // part of name                 ],
            ],
            'test it uses correct languages for association' => [
                (new ProductBuilder($idsCollection, '1000'))
                    ->price(10)
                    ->name('Test product')
                    ->manufacturer('manufacturer', ['de-DE' => ['name' => 'Hersteller']])
                    ->build(),
                $idsCollection,
                [
                    '1000', // productNumber                     'manufacturer', // manufacturer name                     'product', // part of name                     'test', // part of name                 ],
                [
                    '1000', // productNumber                     'Hersteller', // manufacturer name
$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')
                ->property('red', 'color')
                ->property('xl', 'size')
                ->customField('test_int', 19999)
                ->customField('test_date', (new \DateTime())->format('Y-m-d H:i:s'))
                
bool $expected,
        ?bool $parentCloseout,
        ?bool $isCloseout,
        int $minPurchase,
        bool $differentChannel = false
    ): void {
        if (Feature::isActive('v6.6.0.0')) {
            static::markTestSkipped('The load method has been deprecated and will be removed in v6.6.0.0');
        }

        $products = (new ProductBuilder($this->ids, 'a.0'))
            ->manufacturer('m1')
            ->name('test')
            ->price(10)
            ->visibility(TestDefaults::SALES_CHANNEL)
            ->configuratorSetting('red', 'color')
            ->configuratorSetting('xl', 'size')
            ->stock(10)
            ->closeout($parentCloseout)
            ->variant(
                (new ProductBuilder($this->ids, 'a.1'))
                    ->visibility($differentChannel ? $this->ids->get('sales-channel') : TestDefaults::SALES_CHANNEL)
                    ->option('red', 'color')
                    
static::assertNull($deleted);
    }

    private function createProducts(): void
    {
        $taxId = $this->getExistingTaxId();
        $this->ids->set('t1', $taxId);

        $product1 = (new ProductBuilder($this->ids, 'p1'))
            ->price(100)
            ->visibility()
            ->manufacturer('m1')
            ->variant(
                (new ProductBuilder($this->ids, 'v1.1'))
                    ->build()
            );

        $product2 = (new ProductBuilder($this->ids, 'p2'))
            ->price(200)
            ->visibility()
            ->active(false);

        $product3 = (new ProductBuilder($this->ids, 'p3'))
            
'Rustic Copper Drastic Plastic' => '123123123',
            'Incredible Plastic Duoflex' => '765752342',
            'Fantastic Concrete Comveyer' => '834157484',
            'Fantastic Copper Ginger Vitro' => '9095345345',
        ];

        $products = [
            (new ProductBuilder($this->ids, 'bmw'))
                ->name(Uuid::randomHex())
                ->visibility($this->ids->get('sales-channel'))
                ->price(10, 9)
                ->manufacturer('shopware AG')
                ->add('customSearchKeywords', ['bmw'])
                ->variant(
                    (new ProductBuilder($this->ids, 'bmw.1'))
                        ->visibility($this->ids->get('sales-channel'))
                        ->build()
                )
                ->build(),
            // same as above, but has mercedes as variant             (new ProductBuilder($this->ids, 'mercedes'))
                ->name(Uuid::randomHex())
                ->visibility($this->ids->get('sales-channel'))
                
$facade->search('product', $criteria);
    }

    private function createProducts(): void
    {
        $taxId = $this->getExistingTaxId();
        $this->ids->set('t1', $taxId);

        $product1 = (new ProductBuilder($this->ids, 'p1'))
            ->price(100)
            ->visibility()
            ->manufacturer('m1')
            ->variant(
                (new ProductBuilder($this->ids, 'v1.1'))
                    ->build()
            );

        $product2 = (new ProductBuilder($this->ids, 'p2'))
            ->price(200)
            ->visibility()
            ->active(false);

        $product3 = (new ProductBuilder($this->ids, 'p3'))
            

class ReferenceVersionFieldSerializerTest extends TestCase
{
    use IntegrationTestBehaviour;

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

        $product = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->manufacturer('m1')
            ->build();

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

        $connection = $this->getContainer()->get(Connection::class);

        $value = $connection->fetchOne('SELECT LOWER(HEX(product_manufacturer_version_id)) FROM product WHERE id = :id', ['id' => $ids->getBytes('p1')]);
        static::assertEquals(Defaults::LIVE_VERSION, $value);

        $connection->executeStatement('UPDATE product SET product_manufacturer_version_id = NULL WHERE id = :id', ['id' => $ids->getBytes('p1')]);

        
static::assertTrue($page->hasExtension('myProductAggregations'));
        $extension = $page->getExtension('myProductAggregations');
        static::assertInstanceOf(ArrayStruct::class$extension);
        static::assertEquals(600, $extension->get('sum'));
    }

    private function createProducts(): void
    {
        $product1 = (new ProductBuilder($this->ids, 'p1'))
            ->price(100)
            ->manufacturer('m1')
            ->variant(
                (new ProductBuilder($this->ids, 'v1.1'))
                ->build()
            );

        $product2 = (new ProductBuilder($this->ids, 'p2'))
            ->price(200)
            ->active(false);

        $product3 = (new ProductBuilder($this->ids, 'p3'))
            ->price(300);

        
$productRepo->create([$product4->build()], Context::createDefaultContext());
            },
            false,
            $ids,
        ];
    }

    private function createProducts(IdsCollection $ids): void
    {
        $product1 = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->manufacturer('m1')
            ->variant(
                (new ProductBuilder($ids, 'v1.1'))
                    ->build()
            );

        $product2 = (new ProductBuilder($ids, 'p2'))
            ->price(200)
            ->active(false);

        $product3 = (new ProductBuilder($ids, 'p3'))
            ->price(300);

        
->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'))
                ->name('Leather Red')
                ->add('description', 'Aerodynamic Fooo')
                ->manufacturer('Shopware')
                ->price(50, 50)
                ->build(),
            (new ProductBuilder($ids, 'product-5'))
                ->name('Cycle Suave')
                ->price(50, 50)
                ->tag('Smarthome')
                ->build(),
            (new ProductBuilder($ids, 'product-6'))
                ->name('T-Shirt')
                ->price(50, 50)
                ->variant(
                    (
static::assertEquals($expected[$index]$seoUrl->getSeoPathInfo());
        }
    }

    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());

        
false,
            Response::HTTP_OK,
            'Hello, Max Mustermann',
        ];
    }

    private function createProducts(IdsCollection $ids): void
    {
        $product1 = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->name('My Test-Product')
            ->manufacturer('m1')
            ->variant(
                (new ProductBuilder($ids, 'v1.1'))
                    ->build()
            );

        $salesChannelIds = $this->getContainer()->get(Connection::class)
            ->fetchFirstColumn('SELECT LOWER(HEX(id)) FROM sales_channel');
        foreach ($salesChannelIds as $salesChannelId) {
            $product1->visibility($salesChannelId);
        }

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