/** * 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]); }
/** * {@inheritdoc} */ public function getDefaultValues() { $parameters = $this->simpleProvider->getDefaultValues(); $parameters['decimalSeparator'] = LocalizerInterface::DEFAULT_DECIMAL_SEPARATOR; $parameters['dateFormat'] = LocalizerInterface::DEFAULT_DATE_FORMAT; $parameters['with_media'] = true; $parameters['filePath'] = sys_get_temp_dir() . 'csv_products_export.csv'; $defaultChannel = $this->channelRepository->getFullChannels()[0]; $defaultLocaleCode = $this->localeRepository->getActivatedLocaleCodes()[0]; $parameters['filters'] = ['data' => [['field' => 'enabled', 'operator' => OPERATORS::EQUALS, 'value' => true], ['field' => 'completeness', 'operator' => OPERATORS::GREATER_OR_EQUAL_THAN, 'value' => 100], ['field' => 'categories.code', 'operator' => OPERATORS::IN_CHILDREN_LIST, 'value' => []]], 'structure' => ['scope' => $defaultChannel->getCode(), 'locales' => [$defaultLocaleCode]]]; return $parameters; }
/** * Get completeness for a product * * @param int $id * * @return JSONResponse */ public function getAction($id) { $product = $this->productRepository->getFullProduct($id); if (null === $product->getFamily()) { return new JsonResponse(); } $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')); }
function it_provides_default_values($decoratedProvider, ChannelRepositoryInterface $channelRepository, LocaleRepositoryInterface $localeRepository, LocaleInterface $locale, ChannelInterface $channel) { $channel->getCode()->willReturn('channel_code'); $channelRepository->getFullChannels()->willReturn([$channel]); $locale->getCode()->willReturn('locale_code'); $localeRepository->getActivatedLocaleCodes()->willReturn([$locale]); $decoratedProvider->getDefaultValues()->willReturn(['decoratedParam' => true]); $this->getDefaultValues()->shouldReturnWellFormedDefaultValues(); }
/** * 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')); }
/** * 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(); }