/**
  * Display the products of a group
  *
  * @param string $identifier
  *
  * @return JsonResponse
  *
  * @AclAncestor("pim_enrich_product_index")
  */
 public function listProductsAction($identifier)
 {
     $group = $this->groupRepository->findOneBy(['code' => $identifier]);
     if (!$group) {
         throw new NotFoundHttpException(sprintf('Group with code "%s" not found', $identifier));
     }
     return new JsonResponse($this->normalizer->normalize(['products' => $this->productRepository->getProductsByGroup($group, self::MAX_PRODUCTS), 'productCount' => $this->productRepository->getProductCountByGroup($group)], 'internal_api'));
 }
Ejemplo n.º 2
0
 /**
  * Returns an array containing a limited number of product groups, and the total number of products
  *
  * @param GroupInterface $group
  * @param int            $maxResults
  *
  * @deprecated will be removed in 1.5
  *
  * @return array
  */
 public function getProductList(GroupInterface $group, $maxResults)
 {
     $products = $this->productRepository->getProductsByGroup($group, $maxResults);
     $count = $this->productRepository->getProductCountByGroup($group);
     return ['products' => $products, 'productCount' => $count];
 }