/** * Get completeness for a product * * @param int $id * * @return JSONResponse */ public function getAction($id) { $product = $this->productRepository->getFullProduct($id); $this->completenessManager->generateMissingForProduct($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, $this->userContext->getCurrentLocale()->getCode()); return new JsonResponse($this->completenessNormalizer->normalize($completenesses, 'internal_api')); }
/** * Generate a list of potential completeness value from existing channel * or from the provided channel * * @param ChannelInterface $channel * * @return array */ protected function getChannelLocaleCombinations(ChannelInterface $channel = null) { $channels = []; $combinations = []; if (null !== $channel) { $channels = [$channel]; } else { $channels = $this->channelRepository->getFullChannels(); } foreach ($channels as $channel) { $locales = $channel->getLocales(); foreach ($locales as $locale) { $combinations[] = $channel->getCode() . '-' . $locale->getCode(); } } return $combinations; }
/** * Get full channels with locales and currencies * * @return ChannelInterface[] */ public function getFullChannels() { return $this->channelRepository->getFullChannels(); }