作者:abdeldaye
项目:pim-community-de
function let(DocumentManager $manager, ChannelInterface $ecommerce, ChannelInterface $mobile, LocaleInterface $enUs, LocaleInterface $frFr, CategoryInterface $category, ChannelManager $channelManager, CategoryRepositoryInterface $categoryRepository, ProductRepository $productRepository, QueryBuilder $ormQb, Builder $odmQb, Query $odmQuery, Cursor $cursor)
{
$enUs->getCode()->willReturn('en_US');
$frFr->getCode()->willReturn('fr_FR');
$ecommerce->getCode()->willReturn('ecommerce');
$ecommerce->getLabel()->willReturn('ECommerce');
$ecommerce->getLocales()->willReturn(array($enUs, $frFr));
$ecommerce->getCategory()->willReturn($category);
$mobile->getCode()->willReturn('mobile');
$mobile->getLabel()->willReturn('Mobile');
$mobile->getLocales()->willReturn(array($enUs));
$mobile->getCategory()->willReturn($category);
$odmQuery->execute()->willReturn($cursor);
$productRepository->createQueryBuilder()->willReturn($odmQb);
$odmQb->hydrate(Argument::any())->willReturn($odmQb);
$odmQb->field(Argument::any())->willReturn($odmQb);
$odmQb->in(Argument::any())->willReturn($odmQb);
$odmQb->equals(Argument::any())->willReturn($odmQb);
$odmQb->select('_id')->willReturn($odmQb);
$odmQb->getQuery()->willReturn($odmQuery);
$categoryRepository->getAllChildrenQueryBuilder($category, true)->willReturn($ormQb);
$categoryRepository->getCategoryIds($category, $ormQb)->willReturn(array(1, 2, 3));
$channelManager->getFullChannels()->willReturn(array($ecommerce, $mobile));
$manager->getRepository('pim_product_class')->willReturn($productRepository);
$this->beConstructedWith($manager, $channelManager, $categoryRepository, 'pim_product_class');
}
作者:umpirsk
项目:pim-community-de
function it_returns_flat_data_without_media(ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$product->getValues()->willReturn([]);
$serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => ''])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$this->setChannel('foobar');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
作者:ashutosh-srija
项目:findit_akene
function it_throws_an_exception_if_no_file_is_found(ChannelInterface $channel, ProductInterface $product, ChannelManager $channelManager, Serializer $serializer, ProductValueInterface $productValue, AttributeInterface $attribute)
{
$product->getValues()->willReturn([$productValue]);
$productValue->getAttribute()->willReturn($attribute);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$product->getIdentifier()->willReturn($productValue);
$productValue->getData()->willReturn('data');
$this->setChannel('foobar');
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$serializer->normalize(['data'], 'flat', ['field_name' => 'media', 'prepare_copy' => true])->willThrow('Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException');
$this->shouldThrow('Akeneo\\Bundle\\BatchBundle\\Item\\InvalidItemException')->during('process', [$product]);
}
作者:abdeldaye
项目:pim-community-de
function it_returns_flat_data_without_media($productBuilder, ChannelInterface $channel, LocaleInterface $locale, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$localeCodes = ['en_US'];
$channel->getLocales()->willReturn(new ArrayCollection([$locale]));
$channel->getLocaleCodes()->willReturn($localeCodes);
$productBuilder->addMissingProductValues($product, [$channel], [$locale])->shouldBeCalled();
$product->getValues()->willReturn([]);
$this->setDecimalSeparator(',');
$serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => $localeCodes, 'decimal_separator' => ',', 'date_format' => 'yyyy-MM-dd'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$this->setChannel('foobar');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
作者:jacko97
项目:pim-community-de
function let(SecurityContextInterface $securityContext, LocaleManager $localeManager, ChannelManager $channelManager, CategoryManager $categoryManager, TokenInterface $token, User $user, LocaleInterface $en, LocaleInterface $fr, LocaleInterface $de, ChannelInterface $ecommerce, ChannelInterface $mobile, CategoryInterface $firstTree, CategoryInterface $secondTree)
{
$securityContext->getToken()->willReturn($token);
$token->getUser()->willReturn($user);
$en->getCode()->willReturn('en_US');
$fr->getCode()->willReturn('fr_FR');
$de->getCode()->willReturn('de_DE');
$en->isActivated()->willReturn(true);
$fr->isActivated()->willReturn(true);
$de->isActivated()->willReturn(true);
$localeManager->getLocaleByCode('en_US')->willReturn($en);
$localeManager->getLocaleByCode('fr_FR')->willReturn($fr);
$localeManager->getLocaleByCode('de_DE')->willReturn($de);
$localeManager->getActiveLocales()->willReturn([$en, $fr, $de]);
$channelManager->getChannels()->willReturn([$mobile, $ecommerce]);
$categoryManager->getTrees()->willReturn([$firstTree, $secondTree]);
$this->beConstructedWith($securityContext, $localeManager, $channelManager, $categoryManager, 'en_US');
}
作者:abdeldaye
项目:pim-community-de
function it_returns_flat_data_without_media($productBuilder, ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$productBuilder->addMissingProductValues($product)->shouldBeCalled();
$this->setLocale('en_US');
$product->getValues()->willReturn([]);
$serializer->normalize($product, 'flat', ['scopeCode' => 'mobile', 'localeCodes' => '', 'locale' => 'en_US'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('mobile')->willReturn($channel);
$this->setChannelCode('mobile');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
作者:noglitchy
项目:pim-community-de
/**
* @param ChannelManager $channelManager
*/
public function __construct(ChannelManager $channelManager)
{
$this->channels = $channelManager->getChannels();
}
作者:qrz-i
项目:pim-community-de
function it_returns_flat_data_without_media($dateformatProvider, $numberFormatProvider, ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$dateformatProvider->getFormat('en_US')->willReturn('n/j/y');
$numberFormatProvider->getFormat('en_US')->willReturn(['decimal_separator' => '.']);
$this->configureOptions('en_US');
$product->getValues()->willReturn([]);
$serializer->normalize($product, 'flat', ['scopeCode' => 'mobile', 'localeCodes' => '', 'decimal_separator' => '.', 'date_format' => 'n/j/y'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('mobile')->willReturn($channel);
$this->setChannelCode('mobile');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
作者:rskonieczk
项目:MagentoConnectorBundl
/**
* Get all Pim locales for the given channel.
*
* @param string $channel
*
* @return array
*/
protected function getPimLocales($channel)
{
if (!$this->pimLocales) {
$this->pimLocales = $this->channelManager->getChannelByCode($channel)->getLocales();
}
return $this->pimLocales;
}
作者:noglitchy
项目:pim-community-de
/**
* 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));
}
作者:abdeldaye
项目:pim-community-de
/**
* {@inheritdoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$values = null !== $view->vars['value'] ? $view->vars['value']->getValues() : [];
$view->vars['groups'] = $this->productFormView->getView();
$view->vars['orderedGroups'] = $this->getOrderedGroups($values);
$view->vars['locales'] = $this->userContext->getUserLocales();
$view->vars['channels'] = $this->channelManager->getChannels();
$view->vars['currentLocale'] = $options['currentLocale'];
}
作者:ashutosh-srija
项目:findit_akene
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
$channels = $this->manager->getChannelChoices();
if (0 === count($channels)) {
throw new ConstraintDefinitionException('No channel is set in the application');
}
$constraint->choices = array_keys($channels);
parent::validate($value, $constraint);
}
作者:techpu
项目:EnhancedConnectorBundl
/**
* {@inheritdoc}
*/
public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
{
$this->checkValue($field, $value, $locale, $scope);
$channel = $this->channelManager->getChannelByCode($scope);
foreach ($channel->getLocales() as $locale) {
$field = sprintf("%s.%s.%s-%s", ProductQueryUtility::NORMALIZED_FIELD, 'completenesses', $scope, $locale);
$value = intval($value);
$this->qb->addOr($this->getExpr($value, $field, $operator));
}
return $this;
}
作者:mejdoubimerie
项目:prestashopconnecto
/**
* Checks if the passed value is valid.
*
* @param AbstractProductProcessor $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*
* @api
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof AbstractProductProcessor) {
return null;
}
if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) {
foreach ($channel->getLocales() as $locale) {
if ($locale->getCode() === $value->getDefaultLocale()) {
return null;
}
}
}
$this->context->addViolationAt('defaultLocale', $constraint->message, ['defaultLocale']);
}
作者:jarock
项目:MagentoConnectorBundl
/**
* Checks if the passed value is valid.
*
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*
* @api
* @return null
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof AbstractProductProcessor) {
return null;
}
if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) {
foreach ($channel->getCurrencies() as $currency) {
if ($currency->getCode() === $value->getCurrency()) {
return null;
}
}
}
$this->context->addViolationAt('currency', $constraint->message, ['currency']);
}
作者:noglitchy
项目:pim-community-de
/**
* Edit a family
*
* TODO : find a way to use param converter with interfaces
*
* @param Family $family
*
* @Template
* @AclAncestor("pim_enrich_family_index")
*
* @return array
*/
public function editAction(Family $family)
{
if ($this->familyHandler->process($family)) {
$this->addFlash('success', 'flash.family.updated');
}
return ['form' => $this->familyForm->createView(), 'attributesForm' => $this->getAvailableAttributesForm($family->getAttributes()->toArray())->createView(), 'channels' => $this->channelManager->getChannels()];
}
作者:javiersanto
项目:pim-community-de
/**
* Get channel choices with user channel code first
*
* @return string[]
*/
public function getChannelChoicesWithUserChannel()
{
$channelChoices = $this->channelManager->getChannelChoices();
$userChannelCode = $this->getUserChannelCode();
if (array_key_exists($userChannelCode, $channelChoices)) {
return [$userChannelCode => $channelChoices[$userChannelCode]] + $channelChoices;
}
return $channelChoices;
}
作者:javiersanto
项目:pim-community-de
/**
* Return rows for available channels and theirs locales
*
* @param AbstractAttribute $attribute
*
* @return array
*/
protected function getScopeToLocaleRows(AbstractAttribute $attribute)
{
$channels = $this->channelManager->getChannels();
$scopeToLocaleRows = array();
foreach ($channels as $channel) {
foreach ($channel->getLocales() as $locale) {
$scopeToLocaleRows[] = array('attribute' => $attribute->getCode(), 'locale' => $locale->getCode(), 'scope' => $channel->getCode());
}
}
return $scopeToLocaleRows;
}
作者:userz5
项目:pim-community-de
/**
* Edit a family
*
* @param int $id
*
* @Template
* @AclAncestor("pim_enrich_family_index")
*
* @return array
*/
public function editAction($id)
{
$family = $this->familyRepository->find($id);
if (null === $family) {
throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
}
if ($this->familyHandler->process($family)) {
$this->request->getSession()->getFlashBag()->add('success', new Message('flash.family.updated'));
}
return ['form' => $this->familyForm->createView(), 'attributesForm' => $this->getAvailableAttributesForm($family->getAttributes()->toArray())->createView(), 'channels' => $this->channelManager->getChannels()];
}
作者:jacko97
项目:pim-community-de
/**
* {@inheritdoc}
*/
public function getCompleteProductsCountPerChannels()
{
$channels = $this->channelManager->getFullChannels();
$productRepo = $this->documentManager->getRepository($this->productClass);
$productsCount = array();
foreach ($channels as $channel) {
$category = $channel->getCategory();
$categoryQb = $this->categoryRepository->getAllChildrenQueryBuilder($category, true);
$categoryIds = $this->categoryRepository->getCategoryIds($category, $categoryQb);
foreach ($channel->getLocales() as $locale) {
$data = array();
$compSuffix = $channel->getCode() . '-' . $locale->getCode();
$qb = $productRepo->createQueryBuilder()->hydrate(false)->field('categoryIds')->in($categoryIds)->field('enabled')->equals(true)->field('normalizedData.completenesses.' . $compSuffix)->equals(100)->select('_id');
$localeCount = $qb->getQuery()->execute()->count();
$data['locale'] = $locale->getCode();
$data['label'] = $channel->getLabel();
$data['total'] = $localeCount;
$productsCount[] = $data;
}
}
return $productsCount;
}