Marketing example

/** @var StoreFrontEmotionDeviceConfiguration $service */
        $service = $this->get(\Shopware\Bundle\EmotionBundle\Service\StoreFrontEmotionDeviceConfigurationInterface::class);
        $emotions = $service->getCategoryConfiguration($categoryId$context);

        $categoryContent = Shopware()->Modules()->Categories()->sGetCategoryContent($categoryId);

        $this->View()->assign([
            'hasCustomerStreamEmotion' => $this->container->get(\Shopware\Models\CustomerStream\CustomerStreamRepositoryInterface::class)->hasCustomerStreamEmotions($categoryId),
            'emotions' => $emotions,
            'hasEmotion' => !empty($emotions),
            'sCategoryContent' => $categoryContent,
            'sBanner' => Shopware()->Modules()->Marketing()->sBanner($categoryId),
        ]);
    }

    /** * Handle theme preview hash * * @return bool */
    private function handleThemeHash()
    {
        $hash = $this->Request()->getParam('themeHash');

        
        if (empty($categoryContent) || !$categoryContent['blog']) {
            throw new Enlight_Controller_Exception(sprintf('Blog category by id "%d" is invalid', $categoryId), 404);
        }

        if (!empty($categoryContent['external'])) {
            $this->redirect($categoryContent['external']['code' => 301]);

            return;
        }

        $assigningData = [
            'sBanner' => $this->get('modules')->Marketing()->sBanner($categoryId),
            'sBreadcrumb' => $this->getCategoryBreadcrumb($categoryId),
            'sCategoryContent' => $categoryContent,
            'sNumberArticles' => $totalResult,
            'sPage' => $page,
            'sPerPage' => $perPage,
            'sFilterDate' => $this->getDateFilterData($blogCategoryIds$filter$shopId),
            'sFilterAuthor' => $this->getAuthorFilterData($blogCategoryIds$filter$shopId),
            'sFilterTags' => $this->getTagsFilterData($blogCategoryIds$filter$shopId),
            'sCategoryInfo' => $categoryContent,
            'sBlogArticles' => $blogArticles,
            'sNumberPages' => (int) ceil($totalResult / $perPage),
        ];
/** * @deprecated in 5.6, will be private in 5.8 * * Returns mailing details by mailing id. * * @param int $id * * @return array */
    public function getMailingDetails($id)
    {
        $details = Shopware()->Modules()->Marketing()->sMailCampaignsGetDetail((int) $id);
        if (!\is_array($details)) {
            return [];
        }

        foreach ($details['containers'] as $key => $container) {
            if ($container['type'] === Container::TYPE_VOUCHER) {
                if (!empty($container['value'])) {
                    $details['voucher'] = $container['value'];
                }
                $details['containers'][$key]['type'] = Container::TYPE_TEXT;
            }
            
public function layoutAction(Request $request)
    {
        $this->View()->loadTemplate('frontend/listing/customer_stream/layout.tpl');

        $categoryId = (int) $request->getParam('sCategory');

        $categoryContent = Shopware()->Modules()->Categories()->sGetCategoryContent($categoryId);

        $config = $this->getEmotionConfiguration($categoryId, true, $categoryContent['streamId'] ?? null);

        $config = array_merge($config[
            'sBanner' => Shopware()->Modules()->Marketing()->sBanner($categoryId),
            'sCategoryContent' => $categoryContent,
            'Controller' => 'listing',
            'params' => $this->Request()->getParams(),
        ]);

        $this->View()->assign($config);
    }

    /** * @return void */
    

    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;
                }
            }
        }
public function getCampaigns($parentId)
    {
        $campaigns = [
            'leftTop' => [],
            'leftMiddle' => [],
            'leftBottom' => [],
            'rightMiddle' => [],
            'rightBottom' => [],
        ];

        foreach ($campaigns as $position => $content) {
            $campaigns[$position] = Shopware()->Modules()->Marketing()->sCampaignsGetList(
                $parentId,
                $position
            );
        }

        return $campaigns;
    }

    public function getCapabilities()
    {
        return [
            
public function tagCloudAction()
    {
        $config = $this->container->get('plugins')->Frontend()->TagCloud()->Config();

        if (empty($config->get('show'))) {
            return;
        }

        $controller = $this->Request()->getParam('sController', $this->Request()->getControllerName());

        if (str_contains($config->get('controller')$controller)) {
            $this->View()->assign('sCloud', $this->container->get('modules')->Marketing()->sBuildTagCloud(
                $this->Request()->getParam('sCategory')
            ));
        }
    }

    /** * Loads the listing count for the provided listing parameters. * Sets a json response with: `facets`, `totalCount` and `products`. * * @return void */
    

    public function errorAction()
    {
        $config = $this->container->get(Config::class);
        if (!$config->get('RelatedArticlesOnArticleNotFound')) {
            throw new Enlight_Controller_Exception('Product not found', 404);
        }

        $this->Response()->setStatusCode($config->get('PageNotFoundCode', 404));
        $this->View()->assign('sRelatedArticles', $this->container->get('modules')->Marketing()->sGetSimilarArticles(
            (int) $this->Request()->getParam('sArticle'),
            (int) $config->get('maxcrosssimilar', 4)
        ));
    }

    /** * Index action method * * Read the product details and base rating form data * Loads on demand a custom template * * @return void */

        $this->Response()->setHeader('x-robots-tag', 'noindex');
    }

    /** * @return void */
    public function init()
    {
        $this->config = Shopware()->Config();
        $this->articleModule = Shopware()->Modules()->Articles();
        $this->marketingModule = Shopware()->Modules()->Marketing();
    }

    /** * 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);

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