getArticleImpressionQuery example


    public function refreshArticleImpression($request)
    {
        $articleId = $request->getParam('articleId');
        $deviceType = $request->getDeviceType();
        if (empty($articleId)) {
            return;
        }
        $shopId = Shopware()->Shop()->getId();
        $repository = Shopware()->Models()->getRepository(ArticleImpression::class);
        $articleImpressionQuery = $repository->getArticleImpressionQuery($articleId$shopId, null, $deviceType);
        $articleImpression = $articleImpressionQuery->getOneOrNullResult();

        // If no Entry for this day exists - create a new one         if ($articleImpression === null) {
            $articleImpression = new ArticleImpression($articleId$shopId, null, 1, $deviceType);
            Shopware()->Models()->persist($articleImpression);
        } else {
            $articleImpression->increaseImpressions();
        }
        Shopware()->Models()->flush();
    }

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