/** * Displays completeness for a product * * @param int $id * * @return Response */ public function completenessAction($id) { $product = $this->productRepository->getFullProduct($id); $channels = $this->channelRepository->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', ['product' => $product, 'channels' => $channels, 'locales' => $locales, 'completenesses' => $completenesses]); }
/** * Get completeness for a product * * @param int|string $id * * @return JSONResponse */ public function getAction($id) { $product = $this->productRepository->getFullProduct($id); if (null === $product->getFamily()) { return new JsonResponse(); } $this->completenessManager->generateMissingForProduct($product); // Product have to be refreshed to have the completeness values generated by generateMissingForProduct() // (on ORM, completeness is not calculated the same way and product doesn't need to be refreshed) if (AkeneoStorageUtilsExtension::DOCTRINE_MONGODB_ODM === $this->storageDriver) { $this->productManager->refresh($product); } $channels = $this->channelRepository->getFullChannels(); $locales = $this->userContext->getUserLocales(); $filteredLocales = $this->collectionFilter->filterCollection($locales, 'pim.internal_api.locale.view'); $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $filteredLocales); return new JsonResponse($this->compNormalizer->normalize($completenesses, 'internal_api')); }