tax example

->name('Latin literature')
                    ->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)
                
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')
                ->property('red', 'color')
                ->property('xl', 'size')
                ->customField('test_int', 19999)
                
$price = random_int(100, 200000) / 100.0;

            shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex()$tax)
                ->visibility()
                ->build();

            $products[] = $product;

            $lineItems[] = $factory->create(['id' => $ids->get($number), 'referencedId' => $ids->get($number)]$this->salesChannelContext);
            $this->addTaxDataToSalesChannel($this->salesChannelContext, $product['tax']);
        }

        $this->productRepository->create($products, Context::createDefaultContext());

        
$price = random_int(100, 200000) / 100.0;

            shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex()$tax)
                ->visibility()
                ->build();

            $products[] = $product;

            $lineItems[] = $factory->create(['id' => $ids->get($number), 'referencedId' => $ids->get($number)]$this->salesChannelContext);
            $this->addTaxDataToSalesChannel($this->salesChannelContext, $product['tax']);
        }

        $this->productRepository->create($products, Context::createDefaultContext());

        
'UPDATE product_search_config_field SET ranking = ? WHERE product_search_config_id = (SELECT id FROM product_search_config WHERE language_id = ?) and field = ?',
                [$value, Uuid::fromHexToBytes(Defaults::LANGUAGE_SYSTEM)$field]
            );
        }
    }

    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'])
                
$price = random_int(100, 200000) / 100.0;

            shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex(), 7)
                ->visibility()
                ->build();

            $products[] = $product;

            $lineItems[] = $factory->create(['id' => $ids->get($number), 'referencedId' => $ids->get($number)]$this->salesChannelContext);
            $this->addTaxDataToSalesChannel($this->salesChannelContext, $product['tax']);
        }

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

        
$ids->set('order', $this->cartService->order($cart$this->salesChannelContext, new RequestDataBag()));
    }

    private function addProducts(Cart $cart, IdsCollection $ids): Cart
    {
        $taxIds = $this->salesChannelContext->getTaxRules()->getIds();
        $ids->set('t1', (string) array_pop($taxIds));

        $this->productRepository->create([
            (new ProductBuilder($ids, 'product'))
                ->price(100)
                ->tax('t1')
                ->visibility()
                ->add('height', 3)
                ->add('width', 3)
                ->add('length', 3)
                ->build(),
        ]$this->salesChannelContext->getContext());

        return $this->addProductToCart($ids->get('product'), 1, $cart$this->cartService, $this->salesChannelContext);
    }

    private function changeTransactionStateToPaid(string $orderId): void
    {
$price = random_int(100, 200000) / 100.0;

            shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex()$tax)
                ->visibility()
                ->build();

            $products[] = $product;

            $lineItems[] = $factory->create(['id' => $ids->get($number), 'referencedId' => $ids->get($number)]$this->salesChannelContext);
            $this->addTaxDataToSalesChannel($this->salesChannelContext, $product['tax']);
        }

        $this->productRepository->create($products, Context::createDefaultContext());

        
private array $dependencies = [];

    public function __construct(
        IdsCollection $ids,
        protected string $productNumber,
        protected int $stock = 1,
        string $taxKey = 't1'
    ) {
        $this->ids = $ids;
        $this->id = $this->ids->create($productNumber);
        $this->name = $productNumber;
        $this->tax($taxKey);
    }

    /** * @return array<mixed> */
    public function build(): array
    {
        $this->fixPricesQuantity();

        return $this->parentBuild();
    }

    
'entity_name' => ProductDefinition::ENTITY_NAME,
            'template' => '{{ product.translated.name }}/{{ product.productNumber }}',
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $ids = new IdsCollection();
        $product = (new ProductBuilder($ids, 'parent'))
            ->price(100)
            ->visibility($this->salesChannelId)
            ->variant(
                (new ProductBuilder($ids, 'red'))
                    ->tax(null)
                    ->name('red')
                    ->build()
            )
            ->variant(
                (new ProductBuilder($ids, 'green'))
                    ->name(null)
                    ->build()
            );

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

        

    private function addProducts(Cart $cart, array $productDownloads): Cart
    {
        $ids = new IdsCollection();
        $taxIds = $this->salesChannelContext->getTaxRules()->getIds();
        $ids->set('t1', (string) array_pop($taxIds));
        $products = [];

        foreach ($productDownloads as $key => $downloadFiles) {
            $products[] = (new ProductBuilder($ids, 'product-' . $key))
                ->price(1.0)
                ->tax('t1')
                ->visibility()
                ->add('downloads', array_map(function Dstring $file): array {
                    [$fileName$fileExtension] = explode('.', $file);

                    return [
                        'media' => [
                            'id' => Uuid::randomHex(),
                            'fileName' => $fileName,
                            'fileExtension' => $fileExtension,
                            'private' => true,
                        ],
                    ];
Home | Imprint | This part of the site doesn't use cookies.