@param $articleId

@return ProductStatisticsInterface
342826
public function getStats($articleId)
    {
        $query = 'SELECT * FROM `shop_article_stats` WHERE `shop_article_id` = :articleId';
        $data = $this->databaseConnection->fetchAssoc($query, array('articleId' => $articleId));
        if (is_array($data)) {
            $stats = $this->createStatsObject($data);
        } else {
            $stats = new ProductStatistics();
        }

        return $stats;
    }
1072289
protected function _loadFromDb($articleId)
    {
        $sSelect = $this->buildSelectString([$this->getViewName() . ".oxid" => $articleId]);

        return \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC)->getRow($sSelect);
    }
304991
private function getArticleType(ArticleDocument $articleDocument)
    {
        $structureMetadata = $this->structureMetadataFactory->getStructureMetadata(
            'article',
            $articleDocument->getStructureType()
        );

        return $this->getType($structureMetadata);
    }
453151
public function getProductsInCategoryByMetadata(int $categoryId, array $context) : array
    {
        Assert::that($categoryId)->greaterThan(0, 'The $categoryId has to be positive');
        Assert::that($context)->notEmpty();

        return (array)$this->master->doRequest(
            'POST',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/Products/%d', $categoryId),
            $context
        );
    }
902285
protected function checkProduct($productId)
    {
        $this->product = ProductQuery::create()
            ->findPk($productId)
        ;

        if (null === $this->product) {
            return new JsonResponse(
                [
                    "error" => sprintf(
                        "The product id '%d' doesn't exist",
                        $productId
                    )
                ],
                404
            );
        }

        return null;
    }
1054356
public function get($blogId, $articleId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $endpoint = '/admin/blogs/'.$blogId.'/articles/'.$articleId.'.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createObject(Article::class, $response['article']);
    }
319147
public function updatePartials(int $articleId, array $data): ArticleInterface
    {
        $this->shopware()->put('/api/articles/' . $articleId, [], $data);

        return $this->find($articleId);
    }
599531
public static function GetReviewsForArticleSortedByRate($iShopArticleId)
    {
        $sQuery = "SELECT * FROM `shop_article_review`
                       WHERE `shop_article_review`.`shop_article_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iShopArticleId)."'
                         AND `shop_article_review`.`publish` = '1'
                    ORDER BY `shop_article_review`.`helpful_count` DESC , `shop_article_review`.`datecreated` DESC";
        $oList = &TdbShopArticleReviewList::GetList($sQuery);

        return $oList;
    }
849550
public function fetchProduct($productId)
    {
        /** @var ProductInterface $product */
        $product = $this->getProductRepository()->find($productId);
        if (!$product) {
            throw new EntityNotFoundException($this->getProductRepository()->getClassName(), $productId);
        }

        return $product;
    }
147420
public static function findPublishedByNews($newsId)
    {
        if (0 === \count($ids = Model::getRelatedValues('tl_news', 'categories', $newsId))) {
            return null;
        }

        $t = static::getTableAlias();
        $columns = ["$t.id IN (".\implode(',', \array_map('intval', \array_unique($ids))).')'];
        $values = [];

        if (!BE_USER_LOGGED_IN) {
            $columns[] = "$t.published=?";
            $values[] = 1;
        }

        return static::findBy($columns, $values, ['order' => "$t.sorting"]);
    }
82184
public function getByProductIds(array $productIds, $storeId)
    {
        $searchQueryTable = $this->getTable('search_query');
        $select = $this->getBaseSelect()
            ->joinInner($searchQueryTable, "main_table.query_id = {$searchQueryTable}.query_id", [])
            ->where('product_id IN(?)', $productIds)
            ->where('store_id = ?', $storeId)
            ->columns(['product_id', 'query_id', 'position', 'is_blacklisted']);

        return $this->getConnection()->fetchAll($select);
    }
1205752
public function getAvailableAccessoriesAction($productId, $categoryId)
    {
        $result = array();

        $categories = CategoryQuery::create()->filterById($categoryId)->find();

        if ($categories !== null) {
            $list = ProductQuery::create()
            ->joinWithI18n($this->getCurrentEditionLocale())
            ->filterByCategory($categories, Criteria::IN)
            ->filterById(AccessoryQuery::create()->filterByProductId($productId)->select('accessory')->find(), Criteria::NOT_IN)
            ->find();
            ;

            if ($list !== null) {
                /** @var Product $item */
                foreach ($list as $item) {
                    $result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
                }
            }
        }

        return $this->jsonResponse(json_encode($result));
    }
709155
protected function _deleteRecords($articleId)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $articleId = $oDb->quote($articleId);

        //remove other records
        $sDelete = 'delete from oxobject2article where oxarticlenid = ' . $articleId . ' or oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxobject2attribute where oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxobject2category where oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxobject2selectlist where oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxprice2article where oxartid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxreviews where oxtype="oxarticle" and oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxratings where oxobjectid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxaccessoire2article where oxobjectid = ' . $articleId . ' or oxarticlenid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        //#1508C - deleting oxobject2delivery entries added
        $sDelete = 'delete from oxobject2delivery where oxobjectid = ' . $articleId . ' and oxtype=\'oxarticles\' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxartextends where oxid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        //delete the record
        foreach ($this->_getLanguageSetTables("oxartextends") as $sSetTbl) {
            $oDb->execute("delete from $sSetTbl where oxid = {$articleId}");
        }

        $sDelete = 'delete from oxactions2article where oxartid = ' . $articleId . ' ';
        $oDb->execute($sDelete);

        $sDelete = 'delete from oxobject2list where oxobjectid = ' . $articleId . ' ';

        return $oDb->execute($sDelete);
    }
700258
public function Item($ActivityID = 0) {
      $this->AddJsFile('activity.js');
      $this->Title(T('Activity Item'));

      if (!is_numeric($ActivityID) || $ActivityID < 0)
         $ActivityID = 0;
         
      $this->ActivityData = $this->ActivityModel->GetWhere(array('ActivityID' => $ActivityID));
      $this->SetData('Comments', $this->ActivityModel->GetComments(array($ActivityID)));
      $this->SetData('ActivityData', $this->ActivityData);
      
      $this->Render();
   }
1191942
public function getProductRatingById($productId)
    {
        $this->validateProductId($productId);

        $queryBuilder = $this->queryBuilderFactory->create();
        $queryBuilder
            ->select([
                'OXID',
                'OXRATING',
                'OXRATINGCNT'
            ])
            ->from('oxarticles')
            ->where('oxid = :productId')
            ->setMaxResults(1)
            ->setParameter('productId', $productId);

        return $this->mapper->map(
            new ProductRating(),
            $queryBuilder->execute()->fetch()
        );
    }
44355
public function actionAddAdditional(int $productId, int $languageId)
    {
        $additionalProductsCategories = Category::find()->with('products')
            ->where(['additional_products' => true])->all();

        $productAdditionalProducts = ProductAdditionalProduct::find()->where(['product_id' => $productId])->all();
        return $this->render('../product/save', [
            'viewName' => '../additional-product/add-additional',
            'selectedLanguage' => Language::findOne($languageId),
            'product' => Product::findOne($productId),
            'languages' => Language::find()->all(),

            'params' => [
                'additionalProductsCategories' => $additionalProductsCategories,
                'productAdditionalProducts' => $productAdditionalProducts,
                'productId' => $productId
            ]
        ]);
    }
883397
protected function prepareArticleResponseWhenDetailViewNotAllowed(array $articleResponse, TdbShopArticle $article, $categoryId)
    {
        if ($article->IsVariant()) {
            $oActiveItemParent = $article->GetFieldVariantParent();
            if ($oActiveItemParent && $oActiveItemParent->AllowDetailviewInShop()) {
                $articleResponse['redirectURL'] = $oActiveItemParent->getLink(
                    true,
                    null,
                    array(TdbShopArticle::CMS_LINKABLE_OBJECT_PARAM_CATEGORY => $categoryId)
                );
                $articleResponse['fullURL'] = $articleResponse['redirectURL'];
            }
        }
        $articleResponse['noMatch'] = true;

        return $articleResponse;
    }