ListProduct example

'article'
            );
        }

        if ($premium['configurator_set_id'] > 0) {
            $premium = $this->moduleManager->Articles()->sGetTranslation(
                $premium,
                $premium['variantID'],
                'variant'
            );

            $product = new StoreFrontBundle\Struct\ListProduct(
                $premium['articleID'],
                $premium['variantID'],
                $premium['ordernumber']
            );

            $product->setAdditional($premium['additionaltext']);

            $context = $this->contextService->getShopContext();
            $product = $this->additionalTextService->buildAdditionalText($product$context);
            $premium['additionaltext'] = $product->getAdditional();
        }

        
 else {
                $product = $this->sGetTranslation(
                    $product,
                    $product['id'],
                    'article'
                );
            }
        }

        // If product has variants, we need to append the additional text to the name         if ($product['configurator_set_id'] > 0) {
            $productStruct = new ListProduct(
                (int) $product['id'],
                (int) $product['did'],
                $orderNumber
            );

            $productStruct->setAdditional($product['additionaltext']);

            $context = $this->contextService->getShopContext();
            $productStruct = $this->additionalTextService->buildAdditionalText($productStruct$context);

            if (!$returnAll) {
                
(float) $row['price'],
                    $row['purchaseunit'],
                    $row['referenceunit']
                );
            }
            if ($row['configurator'] > 0) {
                if (empty($this->sSettings['variant_export']) || $this->sSettings['variant_export'] == 1) {
                    $row['group_additionaltext'] = [];

                    if (!empty($row['group_ordernumber'])) {
                        foreach ($row['group_ordernumber'] as $orderNumber) {
                            $product = new ListProduct(
                                (int) $row['articleID'],
                                (int) $row['articledetailsID'],
                                $orderNumber
                            );

                            $product->setAdditional($row['additionaltext']);

                            $product = $this->additionalTextService->buildAdditionalText($product$context);

                            if (\array_key_exists($orderNumber$row['group_additionaltext'])) {
                                $row['group_additionaltext'][$orderNumber] = $product->getAdditional();
                            }
/** * @param array<array<string, mixed>> $result * * @return array<string, ListProduct> */
    private function buildListProducts(array $result): array
    {
        $products = [];
        foreach ($result as $item) {
            $number = (string) $item['Detail_number'];

            $product = new ListProduct(
                $item['Article_id'],
                $item['Detail_id'],
                $item['Detail_number']
            );
            if ($item['Detail_additionalText']) {
                $product->setAdditional($item['Detail_additionalText']);
            }
            $products[$number] = $product;
        }

        return $products;
    }


    /** * @return ListProduct[] */
    private function buildListProducts(array $result)
    {
        $products = [];
        foreach ($result as $item) {
            $number = $item['number'];

            $product = new ListProduct(
                $item['articleId'],
                $item['articleDetailId'],
                $item['number']
            );
            if ($item['additionalText']) {
                $product->setAdditional($item['additionalText']);
            }
            $products[$number] = $product;
        }

        return $products;
    }


    /** * @param array<array<string, mixed>> $products * * @return ListProduct[] */
    private function buildListProducts(array $products): array
    {
        $listProducts = [];
        foreach ($products as $product) {
            $listProduct = new ListProduct($product['articleId']$product['variantId']$product['number']);
            $listProduct->setAdditional($product['additionalText']);
            $listProducts[$product['number']] = $listProduct;
        }

        return $listProducts;
    }

    /** * @param array<array<string, mixed>> $products * * @return array<array<string, mixed>> */
$this->esdHydrator = $esdHydrator;
    }

    /** * Hydrates the passed data and converts the ORM * array values into a Struct\ListProduct class. * * @return ListProduct */
    public function hydrateListProduct(array $data)
    {
        $product = new ListProduct(
            (int) $data['__product_id'],
            (int) $data['__variant_id'],
            $data['__variant_ordernumber']
        );

        return $this->assignData($product$data);
    }

    /** * @return array */
    
$sql = 'SELECT id, ordernumber, additionaltext FROM s_articles_details WHERE articleID = :articleId AND kind != 3';

        $products = [];
        $variantsData = $this->connection->fetchAllAssociative(
            $sql,
            ['articleId' => $productId]
        );

        foreach ($variantsData as $variantData) {
            $product = new ListProduct(
                $productId,
                $variantData['id'],
                $variantData['ordernumber']
            );

            if ($variantData['id'] == $mainVariantId) {
                $variantData = $this->productModule->sGetTranslation(
                    $variantData,
                    $productId,
                    'article'
                );
            }
Home | Imprint | This part of the site doesn't use cookies.