sGetPromotionById example


    public function getSimilarShown($articleID)
    {
        $productIdsInCart = $this->basket->sGetBasketIds();
        Shopware()->Modules()->Marketing()->sBlacklist = $productIdsInCart ?? [];

        $similarProducts = Shopware()->Modules()->Marketing()->sGetSimilaryShownArticles($articleID);

        $similars = [];
        if (!empty($similarProducts)) {
            foreach ($similarProducts as $similarProduct) {
                $temp = Shopware()->Modules()->Articles()->sGetPromotionById('fix', 0, (int) $similarProduct['id']);
                if (!empty($temp)) {
                    $similars[] = $temp;
                }
            }
        }

        return $similars;
    }

    /** * @deprecated in 5.6, will be protected in 5.8 * * Get articles that bought in combination with last added product to * display on cart page * * @param int $articleID * * @return array<array<string, mixed>> */
if ($sBasketAmount >= $premium['startprice']) {
                $premium['available'] = 1;
            } else {
                $premium['available'] = 0;
            }

            if (empty($premium['available'])) {
                $premium['sDifference'] = $this->productModule->sFormatPrice(
                    $premium['startprice'] - $sBasketAmount
                );
            }
            $premium['sArticle'] = $this->productModule->sGetPromotionById(
                'fix',
                0,
                $premium['articleID']
            );
            $premium['startprice'] = $this->productModule->sFormatPrice($premium['startprice']);
            $premium['sVariants'] = $this->getVariantDetailsForPremiumProducts(
                (int) $premium['articleID'],
                (int) $premium['main_detail_id']
            );
        }

        
        foreach ($blogArticleData['media'] as &$media) {
            $mediaId = $media['mediaId'];
            $mediaData = $this->get(LegacyStructConverter::class)->convertMediaStruct($mediaStructs[$mediaId]);
            if ($media['preview']) {
                $blogArticleData['preview'] = $mediaData;
            }
            $media = array_merge($media$mediaData);
        }

        // Add sRelatedArticles         foreach ($blogArticleData['assignedArticles'] as &$assignedArticle) {
            $product = Shopware()->Modules()->Articles()->sGetPromotionById('fix', 0, (int) $assignedArticle['id']);
            if ($product) {
                $blogArticleData['sRelatedArticles'][] = $product;
            }
        }

        // Adding average vote data to the blog article         $avgVoteQuery = $this->repository->getAverageVoteQuery($blogArticleId$shop->getId());
        $blogArticleData['sVoteAverage'] = $avgVoteQuery->getOneOrNullResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);

        // Generate breadcrumb         $breadcrumb = $this->getCategoryBreadcrumb($blogArticleData['categoryId']);
        
if (empty($this->Request()->sDetails)) {
            $id = $this->Request()->sArticle;
        } else {
            $id = $this->Request()->sDetails;
        }

        if (empty($id)) {
            return $this->forward('index', 'index');
        }

        // Get Product-Information         $product = Shopware()->Modules()->Articles()->sGetPromotionById('fix', 0, (int) $id);
        if (empty($product['articleName'])) {
            return $this->forward('index', 'index');
        }

        if ($this->Request()->getPost('sMailTo')) {
            $variables['sError'] = false;
            if (!$this->Request()->getPost('sName')) {
                $variables['sError'] = true;
            }
            if (!$this->Request()->getPost('sMail')) {
                $variables['sError'] = true;
            }
        $checkForProduct = $this->db->fetchAll(
            'SELECT * FROM s_order_comparisons WHERE sessionID=?',
            [$this->session->offsetGet('sessionId')]
        );

        if (!\count($checkForProduct)) {
            return [];
        }

        foreach ($checkForProduct as $product) {
            if ($product['articleID']) {
                $promotion = $this->articleModule->sGetPromotionById('fix', 0, (int) $product['articleID']);
                if (!\is_array($promotion)) {
                    continue;
                }
                $promotion['linkDetails'] = $promotion['linkVariant'];
                $products[] = $promotion;
            }
        }

        $properties = $this->sGetComparisonProperties($products);
        $products = $this->sFillUpComparisonArticles($properties$products);

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