List the product related to one collection.

@param $collectionId

@return Response
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,
        ]);
    }
872356
public function getCollectionById($collectionId)
    {
        $collection = $this->collectionRepository->find($collectionId);
        if (!$collection) {
            throw new CollectionNotFoundException($collectionId);
        }

        return $collection;
    }
53317
protected function collection_query( &$collection ) 
	{
		$local_keys = array();
		
		foreach( $collection as $item )
		{
			$local_keys[] = $item->raw( $this->local_key );
		}
		
		// set the correct collection where
		$this->query->wheres = array();
		$this->query->where( $this->foreign_key, 'in', $local_keys );
		$this->query->group_result( $this->foreign_key );
		
		$this->query->limit( null );
	}
763534
private function retrieveProductById($productId)
    {
        // Fetch product.
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException($productId);
        }

        return $product;
    }
1013358
public function loadById($productId)
    {
        return $this->productRepository->getById($productId, false, $this->storeManager->getStore()->getId(), true);
    }
851582
private function addFilterByParent(ProductCollection $productCollection, $parentId)
    {
        $tableProductRelation = $productCollection->getTable('catalog_product_relation');
        $productCollection->getSelect()->join(
            ['pr' => $tableProductRelation],
            'e.entity_id = pr.child_id'
        )->where('pr.parent_id = ?', $parentId);
    }
91138
public function collectionExists($collectionId, int $status): bool
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('count(*) AS count')
            ->from('ngbm_collection')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collectionId, Type::INTEGER);

        $this->applyStatusCondition($query, $status);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return (int) ($data[0]['count'] ?? 0) > 0;
    }
496208
public function fillCollectionWithRelations(CollectionInterface $collection)
    {
        if (!$collection->count()) {
            return $collection;
        }

        foreach ($this->getWith() as $relation) {
            $relation->fillCollection($collection);
        }

        return $collection;
    }
353890
public function deleteCollection($collectionId, ?int $status = null): void
    {
        // Delete all connections between blocks and collections

        $query = $this->connection->createQueryBuilder();
        $query
            ->delete('ngbm_block_collection')
            ->where(
                $query->expr()->eq('collection_id', ':collection_id')
            )
            ->setParameter('collection_id', $collectionId, Type::INTEGER);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status, 'collection_status');
        }

        $query->execute();

        // Then delete the collection itself

        $query = $this->connection->createQueryBuilder();
        $query->delete('ngbm_collection')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collectionId, Type::INTEGER);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status);
        }

        $query->execute();
    }
1362186
public function setProductTemplateAction($productId)
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
            return $response;
        }

        $product = ProductQuery::create()->findPk($productId);

        if ($product != null) {
            $template_id = \intval($this->getRequest()->get('template_id', 0));

            $this->dispatch(
                TheliaEvents::PRODUCT_SET_TEMPLATE,
                new ProductSetTemplateEvent($product, $template_id, $this->getCurrentEditionCurrency()->getId())
            );
        }

        return $this->redirectToEditionTemplate();
    }
1374001
public function loadProductById($productId)
    {
        $collection = $this->catalogCollection->create()
            ->addFieldToFilter('product_id', $productId)
            ->setPageSize(1);

        return $collection->getFirstItem();
    }
1027820
public function getCollection($collectionId, $fields = ['*'])
    {
        $apiUrl = $this->getEndpoint('collections');
        $apiUrl .= $collectionId;

        $params = array(
            'fields' => implode(',', $fields)
        );

        $apiData = $this->apiGet($apiUrl, $params);

        return $this->decodeSingle($apiData);
    }
1373928
public function index()
    {
        $productsBuilder = $this
            ->repository
            ->query()
            ->where('type', '!=', 'VARIABLE_PRODUCT')
            ->orderBy('id', 'desc');

        $productGrid = new ProductDataGrid($productsBuilder);

        return view('avored-framework::product.index')
            ->with('dataGrid', $productGrid->dataGrid);
    }
720893
public function getAvailableRelatedContentAction($productId, $folderId)
    {
        $result = array();

        $folders = FolderQuery::create()->filterById($folderId)->find();

        if ($folders !== null) {
            $list = ContentQuery::create()
                ->joinWithI18n($this->getCurrentEditionLocale())
                ->filterByFolder($folders, Criteria::IN)
                ->filterById(ProductAssociatedContentQuery::create()->filterByProductId($productId)->select('content_id')->find(), Criteria::NOT_IN)
                ->find();
            ;

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

        return $this->jsonResponse(json_encode($result));
    }
630310
public function listAction()
    {
        $products = $this->container->get('vespolina.product_manager')->findBy(array());

        return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:list.html.'.$this->getEngine(), array('products' => $products));
    }
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,
            ]
        ]);
    }
399213
function removeItem( $itemID )
    {
        $item = eZProductCollectionItem::fetch( $itemID );
        if ( is_object( $item ) && $this->attribute( 'productcollection_id' ) == $item->attribute( 'productcollection_id' ) )
        {
            $item->remove();
        }
    }