/** * {@inheritdoc} */ protected function findEntity($class, array $data) { if (!$this->identifierAttribute) { throw new MissingIdentifierException(); } return $this->productManager->getProductRepository()->findOneByIdentifier($data[$this->identifierAttribute->getCode()]); }
/** * Displays completeness for a product * * @param int $id * * @return Response */ public function completenessAction($id) { $product = $this->productManager->getProductRepository()->getFullProduct($id); $channels = $this->channelManager->getFullChannels(); $locales = $this->userContext->getUserLocales(); $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $locales, $this->userContext->getCurrentLocale()->getCode()); return $this->templating->renderResponse('PimEnrichBundle:Completeness:_completeness.html.twig', array('product' => $product, 'channels' => $channels, 'locales' => $locales, 'completenesses' => $completenesses)); }
/** * @return array */ protected function prepareParameters() { $queryParameters = parent::prepareParameters(); $variantGroupId = $queryParameters['currentGroup']; if (null !== $variantGroupId) { $productIds = $this->productManager->getProductRepository()->getEligibleProductIdsForVariantGroup($variantGroupId); if (count($productIds) === 0) { $productIds = [0]; } } else { $productIds = [0]; } $queryParameters['productIds'] = $productIds; return $queryParameters; }
/** * Get matching products * * @param GroupInterface $variantGroup the variant group * @param ProductInterface $entity the product * @param array $criteria query criterias * * @return ProductInterface[] */ protected function getMatchingProducts(GroupInterface $variantGroup, ProductInterface $entity = null, array $criteria = []) { if (!$variantGroup->getId()) { return []; } $repository = $this->manager->getProductRepository(); $matchingProducts = $repository->findAllForVariantGroup($variantGroup, $criteria); if ($entity) { $matchingProducts = array_filter($matchingProducts, function ($product) use($entity) { return $product->getId() !== $entity->getId(); }); } return $matchingProducts; }
/** * Prepare available attribute ids * * @param array $productIds */ protected function prepareAvailableAttributeIds($productIds) { $productRepo = $this->productManager->getProductRepository(); $this->attributeIds = $productRepo->getAvailableAttributeIdsToExport($productIds); }
/** * @return ProductRepositoryInterface */ public function getProductRepository() { return $this->productManager->getProductRepository(); }