convertListProductStruct example

$this->legacyStructConverter = $legacyStructConverter;
        $this->variantCoverService = $variantCoverService;
    }

    public function getList(array $numbers, ShopContextInterface $context): array
    {
        $products = $this->listProductService->getList($numbers$context);
        $propertySets = $this->propertyService->getList($products$context);
        $covers = $this->variantCoverService->getList($products$context);
        $details = [];
        foreach ($products as $product) {
            $arrayProduct = $this->legacyStructConverter->convertListProductStruct($product);

            if ($product->hasConfigurator()) {
                $variantPrice = $product->getVariantPrice();
                $arrayProduct['referenceprice'] = $variantPrice->getCalculatedReferencePrice();
            }

            if (isset($covers[$product->getNumber()])) {
                $arrayProduct['image'] = $this->legacyStructConverter->convertMediaStruct($covers[$product->getNumber()]);
            }

            if ($product->hasProperties() && isset($propertySets[$product->getNumber()])) {
                
$product = $productService->get($orderNumber$context);
        if (!$product) {
            $productOrderNumber = $this->get('dbal_connection')->fetchOne(
                'SELECT ordernumber FROM s_addon_premiums WHERE ordernumber_export = :ordernumber',
                [':ordernumber' => $orderNumber]
            );
            if ($productOrderNumber) {
                $product = $productService->get($productOrderNumber$context);
            }
        }
        if ($product) {
            $this->View()->assign('sArticle', $this->get('legacy_struct_converter')->convertListProductStruct($product));
        }
    }

    /** * Rating action method * * Save and review the product rating * * @return void */
    public function ratingAction()
    {
$context = $this->contextService->getShopContext();

        $product = $this->listProductService->get(
            $number,
            $context
        );

        if (!$product) {
            return false;
        }

        $promotion = $this->legacyStructConverter->convertListProductStruct($product);
        if (!empty($category) && $category != $context->getShop()->getCategory()->getId()) {
            $promotion['linkDetails'] .= "&sCategory=$category";
        }

        // check if the product has a configured property set which stored in s_filter.         // the mini product doesn't contains this data so we have to load this lazy.         if (!$product->hasProperties()) {
            return $promotion;
        }

        $propertySet = $this->propertyService->get(
            
$this->listProductService = $listProductService;
        $this->converter = $converter;
        $this->contextService = $contextService;
    }

    public function resolve(): void
    {
        if (!empty($this->resolveIds)) {
            $products = $this->listProductService->getList($this->resolveIds, $this->contextService->getShopContext());

            foreach ($products as $product) {
                $this->storage[$product->getNumber()] = $this->converter->convertListProductStruct($product);
            }

            $this->resolveIds = [];
        }
    }
}
return $this->get(RouterInterface::class)->assemble($assembleParams);
        }

        return false;
    }

    private function convertProducts(ProductSearchResult $result): ?array
    {
        $products = [];
        foreach ($result->getProducts() as $product) {
            $productArray = $this->get(LegacyStructConverter::class)->convertListProductStruct($product);

            $products[] = $productArray;
        }

        if (empty($products)) {
            return null;
        }

        return $products;
    }

    


                $media = $this->converter->convertMediaStruct($element->getData()->get('media'));
                $elementArray['data'] = array_merge($elementArray['data']$media);
                break;

            case ArticleComponentHandler::COMPONENT_NAME:
                if (!$element->getData()->get('product')) {
                    break;
                }

                $product = $this->converter->convertListProductStruct($element->getData()->get('product'));

                if ($element->getConfig()->get('article_type') === ArticleComponentHandler::TYPE_STATIC_VARIANT) {
                    $product['linkDetails'] = $product['linkVariant'];
                }

                $elementArray['data'] = array_merge($elementArray['data']$product);
                break;

            case ArticleSliderComponentHandler::COMPONENT_NAME:
                if (
                    !$element->getData()->get('products')
                    

        }
    }

    /** * @return array */
    private function convertProducts(ProductSearchResult $result)
    {
        $products = [];
        foreach ($result->getProducts() as $product) {
            $productArray = $this->get(LegacyStructConverter::class)->convertListProductStruct($product);

            $productArray['link'] = $this->Front()->ensureRouter()->assemble([
                'controller' => 'detail',
                'sArticle' => $product->getId(),
                'number' => $product->getNumber(),
                'title' => $product->getName(),
            ]);
            $productArray['name'] = $product->getName();
            $products[] = $productArray;
        }

        


        $data['sLinks'][] = [
            'supplierSearch' => true,
            'description' => $product->getManufacturer()->getName(),
            'target' => '_parent',
            'link' => $this->getSupplierListingLink($product->getManufacturer()),
        ];

        $data['sRelatedArticles'] = [];
        foreach ($product->getRelatedProducts() as $relatedProduct) {
            $data['sRelatedArticles'][] = $this->convertListProductStruct($relatedProduct);
        }

        $data['sSimilarArticles'] = [];
        foreach ($product->getSimilarProducts() as $similarProduct) {
            $data['sSimilarArticles'][] = $this->convertListProductStruct($similarProduct);
        }

        $data['relatedProductStreams'] = [];
        foreach ($product->getRelatedProductStreams() as $relatedProductStream) {
            $data['relatedProductStreams'][] = $this->convertRelatedProductStreamStruct($relatedProductStream);
        }

        


    /** * @throws \Exception * * @return array */
    private function convertListProductToNote(ListProduct $product, array $note)
    {
        $structConverter = Shopware()->Container()->get(\Shopware\Components\Compatibility\LegacyStructConverter::class);
        /** @var array $promotion */
        $promotion = $structConverter->convertListProductStruct($product);

        $promotion['id'] = $note['id'];
        $promotion['datum_add'] = $note['datum'];
        $promotion['articlename'] = $promotion['articleName'];
        if ($product->hasConfigurator() && $product->getAdditional()) {
            $promotion['articlename'] .= ' ' . $product->getAdditional();
        }

        $promotion['linkDelete'] = $this->config->get('sBASEFILE') . '?sViewport=note&sDelete=' . $note['id'];

        return $promotion;
    }
$shopContext = Context::createFromShop($shop$this->get(Shopware_Components_Config::class));
            $this->get(RouterInterface::class)->setContext($shopContext);
            $sContext = $this->get(ContextServiceInterface::class)->createShopContext($notify['language']);

            $productInformation = $this->get(ListProductServiceInterface::class)->get($notify['ordernumber']$sContext);

            if (empty($productInformation)) {
                continue;
            }

            $productInformation = $this->get('legacy_struct_converter')->convertListProductStruct($productInformation);

            $link = Shopware()->Front()->ensureRouter()->assemble([
                'sViewport' => 'detail',
                'sArticle' => $product['articleID'],
                'number' => $product['ordernumber'],
            ]);

            $context = [
                'sNotifyData' => $notify,
                'sArticleLink' => $link,
                'sOrdernumber' => $notify['ordernumber'],
                
Home | Imprint | This part of the site doesn't use cookies.