getProductNumber example

$criteria->addFilter(new EqualsFilter('orderId', $orderId));

        $orderLineItem = $this->orderLineItemRepository->search($criteria$context)->first();
        static::assertInstanceOf(OrderLineItemEntity::class$orderLineItem);

        $this->orderLineItemRepository->update([
            [
                'id' => $orderLineItem->getId(),
                'referencedId' => $newProduct->getId(),
                'productId' => $newProduct->getId(),
                'payload' => [
                    'productNumber' => $newProduct->getProductNumber(),
                ],
            ],
        ]$context);

        $newProduct = $this->productRepository->search(new Criteria([$newProductId])$context)->first();
        $originalProduct = $this->productRepository->search(new Criteria([$originalProductId])$context)->first();

        static::assertInstanceOf(ProductEntity::class$newProduct);
        static::assertInstanceOf(ProductEntity::class$originalProduct);
        $this->assertStock(5, $originalProduct);
        $this->assertStock(4, $newProduct);
    }
$this->productConfiguratorSettingRepository
        );
        $serializer->setRegistry($this->getContainer()->get(SerializerRegistry::class));

        $serialized = iterator_to_array($serializer->serialize(new Config([][][])$productDefinition$product));

        static::assertNotEmpty($serialized);

        static::assertSame($product->getId()$serialized['id']);
        static::assertSame($product->getTranslations()->first()->getName()$serialized['translations']['DEFAULT']['name']);
        static::assertSame((string) $product->getStock()$serialized['stock']);
        static::assertSame($product->getProductNumber()$serialized['productNumber']);
        static::assertSame('1', $serialized['active']);
        static::assertStringContainsString('shopware-logo.png', $serialized['cover']['media']['url']);
        static::assertStringContainsString('shopware-icon.png', $serialized['media']);
        static::assertStringContainsString('shopware-background.png', $serialized['media']);
        static::assertStringNotContainsString('shopware-logo.png', $serialized['media']);

        $deserialized = iterator_to_array($serializer->deserialize(new Config([][][])$productDefinition$serialized));

        static::assertSame($product->getId()$deserialized['id']);
        static::assertSame($product->getTranslations()->first()->getName()$deserialized['translations'][Defaults::LANGUAGE_SYSTEM]['name']);
        static::assertSame($product->getStock()$deserialized['stock']);
        
$criteria->addFilter(new EqualsFilter('orderId', $orderId));

        $orderLineItem = $this->orderLineItemRepository->search($criteria$context)->first();
        static::assertInstanceOf(OrderLineItemEntity::class$orderLineItem);

        $this->orderLineItemRepository->update([
            [
                'id' => $orderLineItem->getId(),
                'referencedId' => $newProduct->getId(),
                'productId' => $newProduct->getId(),
                'payload' => [
                    'productNumber' => $newProduct->getProductNumber(),
                ],
            ],
        ]$context);

        $newProduct = $this->productRepository->search(new Criteria([$newProductId])$context)->first();
        $originalProduct = $this->productRepository->search(new Criteria([$originalProductId])$context)->first();

        static::assertInstanceOf(ProductEntity::class$newProduct);
        static::assertInstanceOf(ProductEntity::class$originalProduct);
        static::assertSame(5, $originalProduct->getAvailableStock());
        static::assertSame(4, $newProduct->getAvailableStock());
    }
'_uniqueIdentifier' => $id . '_' . Defaults::LANGUAGE_SYSTEM,
                ]),
            ]),
        ]);
        $product->setUniqueIdentifier($id);

        $result = iterator_to_array($entityPipe->in($config$product->jsonSerialize()));

        static::assertSame($product->getId()$result['id']);
        static::assertSame($product->getTranslations()->first()->getName()$result['translations']['DEFAULT']['name']);
        static::assertSame((string) $product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame('1', $result['active']);

        $result = iterator_to_array($entityPipe->out($config$result));

        static::assertSame($product->getId()$result['id']);
        static::assertSame($product->getTranslations()->first()->getName()$result['translations'][Defaults::LANGUAGE_SYSTEM]['name']);
        static::assertSame($product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame($product->getActive()$result['active']);
    }
}
private readonly AbstractProductSearchRoute $productSearchRoute
    ) {
    }

    #[Route(path: '/search', name: 'frontend.search.page', defaults: ['_httpCache' => true], methods: ['GET'])]     public function search(SalesChannelContext $context, Request $request): Response
    {
        try {
            $page = $this->searchPageLoader->load($request$context);
            if ($page->getListing()->getTotal() === 1) {
                $product = $page->getListing()->first();
                if ($request->get('search') === $product->getProductNumber()) {
                    $productId = $product->getId();

                    return $this->forwardToRoute('frontend.detail.page', []['productId' => $productId]);
                }
            }
        } catch (RoutingException $e) {
            if ($e->getErrorCode() !== RoutingException::MISSING_REQUEST_PARAMETER_CODE) {
                throw $e;
            }

            return $this->forwardToRoute('frontend.home.page');
        }
$purchasePrices = $purchasePricesCollection->getCurrencyPrice(Defaults::CURRENCY);
        }

        $payload = [
            'isCloseout' => $product->getIsCloseout(),
            'customFields' => $product->getCustomFields(),
            'createdAt' => $product->getCreatedAt() ? $product->getCreatedAt()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'releaseDate' => $product->getReleaseDate() ? $product->getReleaseDate()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'isNew' => $product->isNew(),
            'markAsTopseller' => $product->getMarkAsTopseller(),
            'purchasePrices' => $purchasePrices ? json_encode($purchasePrices, \JSON_THROW_ON_ERROR) : null,
            'productNumber' => $product->getProductNumber(),
            'manufacturerId' => $product->getManufacturerId(),
            'taxId' => $product->getTaxId(),
            'tagIds' => $product->getTagIds(),
            'categoryIds' => $product->getCategoryTree(),
            'propertyIds' => $product->getPropertyIds(),
            'optionIds' => $product->getOptionIds(),
            'options' => $product->getVariation(),
            'streamIds' => $product->getStreamIds(),
            'parentId' => $product->getParentId(),
            'stock' => $product->getStock(),
        ];

        
$product = $products->get($child);

        $currencyPrice = $product->getCurrencyPrice(Defaults::CURRENCY);
        static::assertInstanceOf(Price::class$currencyPrice);
        static::assertSame(13.0, $currencyPrice->getGross());
        $manufacturer = $product->getManufacturer();
        static::assertInstanceOf(ProductManufacturerEntity::class$manufacturer);
        static::assertSame('test3', $manufacturer->getName());
        $tax = $product->getTax();
        static::assertInstanceOf(TaxEntity::class$tax);
        static::assertSame(15.0, $tax->getTaxRate());
        static::assertSame('SW200', $product->getProductNumber());
        static::assertSame('Child transformed to parent', $product->getName());
    }

    public function testVariantInheritanceWithTax(): void
    {
        $redId = Uuid::randomHex();
        $greenId = Uuid::randomHex();
        $parentId = Uuid::randomHex();

        $parentTaxId = Uuid::randomHex();
        $greenTaxId = Uuid::randomHex();

        
$metaInformation->setMetaTitle((string) $page->getProduct()->getTranslation('metaTitle'));

            return;
        }

        $metaTitleParts = [$page->getProduct()->getTranslation('name')];

        foreach ($page->getSelectedOptions() as $option) {
            $metaTitleParts[] = $option->getTranslation('name');
        }

        $metaTitleParts[] = $page->getProduct()->getProductNumber();

        $metaInformation->setMetaTitle(implode(' | ', $metaTitleParts));
    }

    /** * @@deprecated tag:v6.6.0 - will be removed because cms page id will always be set */
    private function loadDefaultAdditions(SalesChannelProductEntity $product, ProductPage $page, Request $request, SalesChannelContext $context): void
    {
        if ($cmsPage = $product->getCmsPage()) {
            $page->setCmsPage($cmsPage);

            
/** @var ProductEntity $old */
        $old = $entities->get($id);
        /** @var ProductEntity $new */
        $new = $entities->get($newId);
        static::assertInstanceOf(ProductEntity::class$old);
        static::assertInstanceOf(ProductEntity::class$new);

        static::assertSame($old->getName()$new->getName());
        static::assertSame($old->getTags()$new->getTags());
        static::assertSame($old->getTagIds()$new->getTagIds());
        static::assertNotSame($old->getProductNumber()$new->getProductNumber());
    }

    public function testCloneWithoutChildren(): void
    {
        $ids = new TestDataCollection();

        $data = [
            'id' => $ids->create('parent'),
            'name' => 'parent',
            'children' => [
                ['id' => $ids->create('child-1'), 'name' => 'child'],
                [
Home | Imprint | This part of the site doesn't use cookies.