sGetSimilaryShownArticles 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;
                }
            }
        }

        
/** * Show similar viewed articles */
    public function viewedAction()
    {
        $productId = (int) $this->Request()->getParam('articleId');
        $maxPages = (int) $this->config->get('similarViewedMaxPages', 10);
        $perPage = (int) $this->config->get('similarViewedPerPage', 4);

        $this->marketingModule->sBlacklist[] = $productId;
        $products = $this->marketingModule->sGetSimilaryShownArticles($productId$maxPages * $perPage);

        $numbers = array_column($products, 'number');
        $result = $this->getPromotions($numbers);

        $this->View()->assign('maxPages', $maxPages);
        $this->View()->assign('perPage', $perPage);
        $this->View()->assign('viewedArticles', $result);
    }

    /** * Show also bought articles */
Home | Imprint | This part of the site doesn't use cookies.