@param $productId
@return JsonResponse

List a product pses
978092
public function listAction($productId)
    {
        $this->checkAuth(AdminResources::PRODUCT, [], AccessManager::VIEW);

        if (null !== $response = $this->checkProduct($productId)) {
            return $response;
        }

        $request = $this->getRequest();

        if ($request->query->has('id')) {
            $request->query->remove('id');
        }

        $params = array_merge(
            array(
                "limit" => 10,
                "offset" => 0,
            ),
            $request->query->all(),
            array(
                "product" => $productId,
            )
        );

        return new JsonResponse($this->getProductSaleElements($params));
    }
56226
protected function addListItems( $productId, array $productIds )
	{
		if( empty( $productIds ) ) {
			return;
		}

		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
		$item = $manager->createItem();

		foreach( $productIds as $pos => $refid )
		{
			$item->setId( null );
			$item->setParentId( $productId );
			$item->setDomain( 'product' );
			$item->setType( 'bought-together' );
			$item->setPosition( $pos );
			$item->setRefId( $refid );
			$item->setStatus( 1 );

			$manager->saveItem( $item, false );
		}
	}
961888
public function listProductsAction($collectionId)
    {
        $pager = $this->get('sonata.product.set.manager')
            ->getProductsByCollectionIdPager($collectionId, $this->getCurrentRequest()->get('page'));

        return $this->render('SonataProductBundle:Collection:list_products.html.twig', [
            'pager' => $pager,
        ]);
    }
583841
public function actionRemove($productId)
    {
        if (!empty($productId)) {
            if (!Yii::$app->user->isGuest) {
                $model = FavoriteProduct::find()
                    ->where(['product_id' => $productId, 'user_id' => Yii::$app->user->id])->one();
                if (!empty($model)) {
                    $model->delete();
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'You have successfully deleted this product from favorites.');
                    }
                    else {
                        Yii::$app->session->setFlash('success', Yii::t('shop', 'You have successfully deleted this product from favorites.'));
                    }
                }
                else {
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'Error has occurred.');
                    }
                    else {
                        Yii::$app->session->setFlash('error', Yii::t('shop', 'Error has occurred.'));
                    }
                }
                return $this->redirect(Yii::$app->request->referrer);
            }
            throw new ForbiddenHttpException();
        }
        else throw new NotFoundHttpException();
    }
667164
public function create($productId, ProductImage &$productImage)
    {
        $data = $productImage->exportData();
        $endpoint = '/admin/products/'.$productId.'/images.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'image' => $data
            )
        );
        $productImage->setData($response['image']);
    }
248318
protected function getCategoryProductSelect($productIds, $storeId)
    {
        $select = $this->getConnection()->select()
            ->from(['cpi' => $this->getTable($this->getCategoryProductIndexTable($storeId))])
            ->where('cpi.store_id = ?', $storeId)
            ->where('cpi.product_id IN(?)', $productIds);

        return $select;
    }
1022987
public function readProductFamily($productFamilyId, $componentId)
    {
        $service = $this->getService();

        $response      = $service->request('product_families/' . (int)$productFamilyId . '/components/' . (int)$componentId, 'GET');
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
484155
public function create($data, $productId = null)
    {
        if (isset($productId)) {
            return $this->client()->put($data, 'products/{productId}', ['productId' => $productId]);
        }

        return $this->client()->post($data, 'products');
    }
829829
public function getSku($productId, $skuId)
    {
        return $this->client->get("/products/" . rawurlencode($productId) . "/skus/" . rawurlencode($skuId));
    }
589053
protected function findProductModelById(string $id): ?ProductInterface
    {
        /**
         * @var ProductInterface
         */
        $class = $this->modelBuilder->getInterfaceClass($this->config, ProductInterface::class);

        return $class::findProductBy1c($id);
    }
345351
public function count($productId, array $params = array())
    {
        $endpoint = '/admin/products/'.$productId.'/images/count.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $response['count'];
    }
1250215
public function getItems($product_id)
    {
        $product_ids = array();
        foreach ($this->getList(array('product_id' => $product_id)) as $item) {
            $product_ids[] = $item['item_product_id'];
        }

        return $product_ids;
    }
886194
public function getSelectedCombinationFromSession($productId)
    {
        $combination = null;

        if (!empty($productId)) {
            $items = Yii::$app->session[self::SESSION_KEY_SELECTED_COMBINATIONS];

            if (!empty($items)) {
                $combinationId = null;

                foreach ($items as $item) {
                    if ($item['productId'] == $productId) {
                        $combinationId = $item['combinationId'];
                    }
                }

                $combination = Combination::findOne($combinationId);
            }
        }

        return $combination;
    }
1297968
public function getRatingsByProductId($productId)
    {
        $queryBuilder = $this->queryBuilderFactory->create();
        $queryBuilder
            ->select('r.*')
            ->from('oxratings', 'r')
            ->where('r.oxobjectid = :productId')
            ->andWhere('r.oxtype = :productType')
            ->orderBy('r.oxtimestamp', 'DESC')
            ->setParameters(
                [
                    'productId'     => $productId,
                    'productType'   => 'oxarticle',
                ]
            );

        return $this->mapRatings($queryBuilder->execute()->fetchAll());
    }
1235865
public function deleteAction($pseId)
    {
        $this->checkAuth(AdminResources::PRODUCT, [], AccessManager::VIEW);

        $results = $this->getProductSaleElements([
            'id' => $pseId
        ]);

        if ($results->getCount() == 0) {
            return new JsonResponse(
                sprintf(
                    "The product sale elements id '%d' doesn't exist",
                    $pseId
                ),
                404
            );
        }

        $event = new ProductSaleElementDeleteEvent($pseId, null);

        try {
            $this->dispatch(TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT, $event);
        } catch (\Exception $e) {
            return new JsonResponse(array("error" => $e->getMessage()), 500);
        }

        return $this->nullResponse(204);
    }
723083
public function actionList(int $productId, int $languageId)
    {

        $product = Product::findOne($productId);
        $products = Product::find()->joinWith('translations')->orderBy('title')->all();
        $relatedProducts = $product->relatedProducts;
        $newRelatedProduct = new RelatedProduct();

        $selectedLanguage = Language::findOne($languageId);
        $languages = Language::find()->all();

        if (\Yii::$app->request->isPost && $newRelatedProduct->load(\Yii::$app->request->post())) {
            if (empty(RelatedProduct::find()
                ->where(['product_id' => $productId, 'related_product_id' => $newRelatedProduct->related_product_id])->one())
            ) {

                $newRelatedProduct->product_id = $productId;
                if ($newRelatedProduct->validate()) $newRelatedProduct->save();
                \Yii::$app->session->setFlash('info', \Yii::t('shop', 'Relation product has added successfully'));
            } else {
                \Yii::$app->session->setFlash('info', \Yii::t('shop', 'Such relation product already exists for this product'));
            }

            return $this->redirect(\Yii::$app->request->referrer);
        }

        return $this->render('../product/save', [
            'viewName' => '../related-product/list',
            'selectedLanguage' => $selectedLanguage,
            'product' => $product,
            'languages' => $languages,

            'params' => [
                'product' => $product,
                'products' => $products,
                'relatedProducts' => $relatedProducts,
                'newRelatedProduct' => $newRelatedProduct,
                'languages' => $languages,
                'selectedLanguage' => $selectedLanguage,
            ]
        ]);
    }
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()
        );
    }