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'); }
function it_sanitizes_data_during_finalization($userContext, $attributeRepository, $localizerRegistry, $productValuesFilter, LocaleInterface $fr, AttributeInterface $normalAttr, AttributeInterface $scopableAttr, AttributeInterface $localisableAttr, AttributeInterface $localiedAttr, LocalizerInterface $localizer) { $attributeRepository->findOneByIdentifier('normal_attr')->willReturn($normalAttr); $attributeRepository->findOneByIdentifier('scopable_attr')->willReturn($scopableAttr); $attributeRepository->findOneByIdentifier('localisable_attr')->willReturn($localisableAttr); $attributeRepository->findOneByIdentifier('localised_attr')->willReturn($localiedAttr); $normalAttr->getAttributeType()->willReturn('not_localized'); $scopableAttr->getAttributeType()->willReturn('not_localized'); $localisableAttr->getAttributeType()->willReturn('not_localized'); $localiedAttr->getAttributeType()->willReturn('localized'); $localizerRegistry->getLocalizer('not_localized')->willReturn(null); $localizerRegistry->getLocalizer('localized')->willReturn($localizer); $fr->getCode()->willReturn('fr'); $userContext->getUiLocale()->willReturn($fr); $this->setAttributeLocale('fr'); $this->setAttributeChannel('tablet'); $rawData = ['normal_attr' => [['data' => 'foo', 'scope' => null, 'locale' => null]], 'scopable_attr' => [['data' => 'foo', 'scope' => 'tablet', 'locale' => null], ['data' => 'bar', 'scope' => 'ecommerce', 'locale' => null]], 'localisable_attr' => [['data' => 'foo', 'scope' => null, 'locale' => 'fr'], ['data' => 'bar', 'scope' => null, 'locale' => 'de']], 'localised_attr' => [['data' => [['data' => '45,59', 'currency' => 'EUR'], ['data' => '18,22', 'currency' => 'USD']], 'scope' => null, 'locale' => null]]]; $this->setValues(json_encode($rawData)); $localizer->delocalize([['data' => '45,59', 'currency' => 'EUR'], ['data' => '18,22', 'currency' => 'USD']], ["locale" => "fr"])->willReturn([['data' => '45.59', 'currency' => 'EUR'], ['data' => '18.22', 'currency' => 'USD']]); $sanitizedData = ['normal_attr' => [['data' => 'foo', 'scope' => null, 'locale' => null]], 'scopable_attr' => [['data' => 'foo', 'scope' => 'tablet', 'locale' => null]], 'localisable_attr' => [['data' => 'foo', 'scope' => null, 'locale' => 'fr']], 'localised_attr' => [['data' => [['data' => '45.59', 'currency' => 'EUR'], ['data' => '18.22', 'currency' => 'USD']], 'scope' => null, 'locale' => null]]]; $localizedData = ['normal_attr' => [['data' => 'foo', 'scope' => null, 'locale' => null]], 'scopable_attr' => [['data' => 'foo', 'scope' => 'tablet', 'locale' => null]], 'localisable_attr' => [['data' => 'foo', 'scope' => null, 'locale' => 'fr']], 'localised_attr' => [['data' => [['data' => '45,59', 'currency' => 'EUR'], ['data' => '18,22', 'currency' => 'USD']], 'scope' => null, 'locale' => null]]]; $productValuesFilter->filterCollection($localizedData, 'pim.internal_api.product_values_data.edit')->willReturn($localizedData); $this->finalize(); $this->getValues()->shouldReturn(json_encode($sanitizedData)); }
function it_resolves_eligible_values_for_a_set_of_attributes($localeRepository, $channelRepository, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, AttributeInterface $tax, LocaleInterface $fr, LocaleInterface $en, ChannelInterface $ecom, ChannelInterface $print) { $sku->getCode()->willReturn('sku'); $sku->getAttributeType()->willReturn('pim_catalog_identifier'); $sku->isLocalizable()->willReturn(false); $sku->isScopable()->willReturn(false); $sku->isLocaleSpecific()->willReturn(false); $name->getCode()->willReturn('name'); $name->getAttributeType()->willReturn('pim_catalog_text'); $name->isLocalizable()->willReturn(true); $name->isScopable()->willReturn(false); $name->isLocaleSpecific()->willReturn(false); $desc->getCode()->willReturn('description'); $desc->getAttributeType()->willReturn('pim_catalog_text'); $desc->isLocalizable()->willReturn(true); $desc->isScopable()->willReturn(true); $desc->isLocaleSpecific()->willReturn(false); $tax->getCode()->willReturn('tax'); $tax->getAttributeType()->willReturn('pim_catalog_text'); $tax->isLocalizable()->willReturn(true); $tax->isScopable()->willReturn(false); $tax->isLocaleSpecific()->willReturn(true); $tax->getLocaleSpecificCodes()->willReturn(['fr_FR']); $fr->getCode()->willReturn('fr_FR'); $en->getCode()->willReturn('en_US'); $localeRepository->getActivatedLocales()->willReturn([$fr, $en]); $ecom->getCode()->willReturn('ecommerce'); $ecom->getLocales()->willReturn([$en, $fr]); $print->getCode()->willReturn('print'); $print->getLocales()->willReturn([$en, $fr]); $channelRepository->findAll()->willReturn([$ecom, $print]); $this->resolveEligibleValues([$sku, $name, $desc, $tax])->shouldReturn([['attribute' => 'sku', 'type' => 'pim_catalog_identifier', 'locale' => null, 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => null], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'print'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'print'], ['attribute' => 'tax', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null]]); }
function it_gets_configuration($userContext, LocaleInterface $locale) { $locale->getCode()->willReturn('fr_FR'); $expected = addslashes(json_encode(['filters' => null, 'actions' => ['normalized_values' => '', 'ui_locale' => 'fr_FR', 'attribute_locale' => null]])); $userContext->getUiLocale()->willReturn($locale); $this->getBatchConfig()->shouldReturn($expected); }
function it_provide_product_completeness_if_family_is_not_defined(ProductInterface $product, ChannelInterface $mobile, LocaleInterface $en) { $product->getFamily()->willReturn(null); $en->getCode()->willReturn('en_US'); $mobile->getCode()->willReturn('mobile'); $this->getProductCompleteness($product, [$mobile], [$en], 'en_US')->shouldReturn([['channels' => [['completeness' => null, 'missing' => []]], 'stats' => ['total' => 0, 'complete' => 0], 'locale' => '']]); }
function it_normalizes_locales($localeHelper, LocaleInterface $en) { $en->getCode()->willReturn('en_US'); $localeHelper->getLocaleLabel('en_US')->willReturn('English (America)'); $localeHelper->getDisplayRegion('en_US')->willReturn('America'); $localeHelper->getDisplayLanguage('en_US')->willReturn('English'); $this->normalize($en, 'internal_api')->shouldReturn(['code' => 'en_US', 'label' => 'English (America)', 'region' => 'America', 'language' => 'English']); }
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(); }
function it_normalizes_completeness(Completeness $completeness, ChannelInterface $channel, LocaleInterface $locale) { $channel->getCode()->willReturn('ecommerce'); $locale->getCode()->willReturn('en_US'); $completeness->getChannel()->willReturn($channel); $completeness->getLocale()->willReturn($locale); $completeness->getRatio()->willReturn(42); $this->normalize($completeness, 'mongodb_json', [])->shouldReturn(["ecommerce-en_US" => 42]); }
function it_updates_channel($repository, $saver, $completeness, GenericEvent $event, ChannelInterface $channel, LocaleInterface $localeEn, LocaleInterface $localeFr, LocaleInterface $localeEs) { $event->getSubject()->willReturn($channel); $repository->getDeletedLocalesForChannel($channel)->willReturn([$localeEn]); $completeness->scheduleForChannelAndLocale($channel, $localeEn)->shouldBeCalled(); $localeFr->hasChannel($channel)->willReturn(true); $localeEs->hasChannel($channel)->willReturn(false); $channel->getLocales()->willReturn([$localeFr, $localeEs]); $channel->hasLocale($localeEn)->willReturn(false); $channel->hasLocale($localeFr)->willReturn(true); $localeEn->removeChannel($channel)->shouldBeCalled(); $localeEs->addChannel($channel)->shouldBeCalled(); $saver->saveAll([$localeEn, $localeEs])->shouldBeCalled(); $this->updateChannel($event); }
function it_normalizes_channel(ChannelInterface $channel, CurrencyInterface $eur, CurrencyInterface $usd, LocaleInterface $en, LocaleInterface $fr, CategoryInterface $category) { $channel->getCode()->willReturn('ecommerce'); $channel->getLabel()->willReturn('Ecommerce'); $channel->getCurrencies()->willReturn([$eur, $usd]); $eur->getCode()->willReturn('EUR'); $usd->getCode()->willReturn('USD'); $channel->getLocales()->willReturn([$en, $fr]); $en->getCode()->willReturn('en_US'); $fr->getCode()->willReturn('fr_FR'); $channel->getCategory()->willReturn($category); $category->getCode()->willReturn('Master catalog'); $channel->getConversionUnits()->willReturn(['Weight' => 'Kilogram', 'Size' => 'Centimeter']); $this->normalize($channel)->shouldReturn(['code' => 'ecommerce', 'label' => 'Ecommerce', 'currencies' => 'EUR,USD', 'locales' => 'en_US,fr_FR', 'category' => 'Master catalog', 'conversion_units' => 'Weight: Kilogram, Size: Centimeter']); }
function let(TokenStorageInterface $tokenStorage, LocaleRepositoryInterface $localeRepository, ChannelRepositoryInterface $channelRepository, TokenInterface $token, User $user, LocaleInterface $en, LocaleInterface $fr, LocaleInterface $de, ChannelInterface $ecommerce, ChannelInterface $mobile, CategoryInterface $firstTree, CategoryInterface $secondTree, CategoryRepositoryInterface $productCategoryRepo, RequestStack $requestStack, ChoicesBuilderInterface $choicesBuilder) { $tokenStorage->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); $localeRepository->findOneByIdentifier('en_US')->willReturn($en); $localeRepository->findOneByIdentifier('fr_FR')->willReturn($fr); $localeRepository->findOneByIdentifier('de_DE')->willReturn($de); $localeRepository->getActivatedLocales()->willReturn([$en, $fr, $de]); $channelRepository->findOneBy([])->willReturn($mobile); $productCategoryRepo->getTrees()->willReturn([$firstTree, $secondTree]); $this->beConstructedWith($tokenStorage, $localeRepository, $channelRepository, $productCategoryRepo, $requestStack, $choicesBuilder, 'en_US'); }
function it_normalizes_channel(ChannelInterface $channel, CurrencyInterface $eur, CurrencyInterface $usd, LocaleInterface $en, LocaleInterface $fr, CategoryInterface $category, CategoryTranslationInterface $translation) { $channel->getCode()->willReturn('ecommerce'); $channel->getLabel()->willReturn('Ecommerce'); $channel->getCurrencies()->willReturn([$eur, $usd]); $eur->getCode()->willReturn('EUR'); $usd->getCode()->willReturn('USD'); $channel->getLocales()->willReturn([$en, $fr]); $en->getCode()->willReturn('en_US'); $fr->getCode()->willReturn('fr_FR'); $channel->getCategory()->willReturn($category); $category->getCode()->willReturn('master'); $category->getId()->willReturn(42); $translation->getLabel()->willReturn('label'); $translation->getLocale()->willReturn('en_US'); $category->getTranslations()->willReturn([$translation]); $channel->getConversionUnits()->willReturn(['Weight' => 'Kilogram', 'Size' => 'Centimeter']); $this->normalize($channel)->shouldReturn(['code' => 'ecommerce', 'label' => 'Ecommerce', 'currencies' => ['EUR', 'USD'], 'locales' => ['en_US', 'fr_FR'], 'category' => ['id' => 42, 'code' => 'master', 'labels' => ['en_US' => 'label']], 'conversion_units' => 'Weight: Kilogram, Size: Centimeter']); }
function it_builds_user_product_context_for_normalization($tokenStorage, $localeRepository, $channelRepository, $choicesBuilder, ChannelInterface $userChannel, ChannelInterface $ecommerce, LocaleInterface $fr, LocaleInterface $en, TokenInterface $token, UserInterface $user) { $userChannel->getCode()->willReturn('mobile'); $channelRepository->findOneByIdentifier([])->willReturn($userChannel); $tokenStorage->getToken()->willReturn($token); $token->getUser()->willReturn($user); $channelRepository->findAll()->willReturn([$ecommerce]); $choicesBuilder->buildChoices([$ecommerce])->willReturn(['mobile' => $userChannel, 'ecommerce' => $ecommerce]); $fr->getCode()->willReturn('fr_FR'); $en->getCode()->willReturn('en_US'); $localeRepository->getActivatedLocales()->willReturn([$en, $fr]); $user->getUiLocale()->willReturn($fr); $user->getCatalogScope()->willReturn($userChannel); $this->toArray()->shouldReturn(['locales' => ['en_US', 'fr_FR'], 'channels' => ['mobile', 'ecommerce'], 'locale' => 'fr_FR']); }
function it_removes_indexes_for_locale_when_disabling_it($indexPurger, LocaleInterface $en_US, LifecycleEventArgs $args) { $en_US->isActivated()->willReturn(false); $args->getEntity()->willReturn($en_US); $indexPurger->purgeIndexesFromLocale($en_US)->shouldBeCalled(); $this->postUpdate($args); }
/** * {@inheritdoc} */ public function scheduleForChannelAndLocale(ChannelInterface $channel, LocaleInterface $locale) { $productQb = $this->documentManager->createQueryBuilder($this->productClass); $pullExpr = $productQb->expr()->addAnd($productQb->expr()->field('channel')->equals($channel->getId()))->addAnd($productQb->expr()->field('locale')->equals($locale->getId())); $productQb->update()->multiple(true)->field(sprintf('normalizedData.completenesses.%s-%s', $channel->getCode(), $locale->getCode()))->unsetField()->field('completenesses')->pull($pullExpr)->getQuery()->execute(); }
/** * Remove indexes associated with the provided locale * * @param LocaleInterface $locale */ public function purgeIndexesFromLocale(LocaleInterface $locale) { $localePattern = sprintf('/^%s\\..+-%s/', ProductQueryUtility::NORMALIZED_FIELD, $locale->getCode()); $indexesToRemove = $this->getIndexesMatching($localePattern); $this->removeIndexes($indexesToRemove); }
function it_normalizes_locales(LocaleInterface $locale) { $locale->getCode()->willReturn('en_US'); $locale->isActivated()->willReturn(true); $this->normalize($locale, 'json')->shouldReturn(['code' => 'en_US', 'activated' => true]); }
function it_filters_when_values_data_contains_an_inactive_locale($objectFilter, $attributeRepository, $localeRepository, $channelRepository, AttributeInterface $nameAttribute, AttributeInterface $descriptionAttribute, LocaleInterface $enLocale, LocaleInterface $inactiveLocale, ChannelInterface $mobileChannel, ProductInterface $product) { $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute); $nameAttribute->isLocaleSpecific()->willReturn(false); $nameAttribute->isLocalizable()->willReturn(true); $nameAttribute->isScopable()->willReturn(true); $objectFilter->filterObject($nameAttribute, 'pim.internal_api.attribute.edit', ['product' => $product])->willReturn(false); $attributeRepository->findOneByIdentifier('description')->willReturn($descriptionAttribute); $descriptionAttribute->isLocaleSpecific()->willReturn(false); $descriptionAttribute->isLocalizable()->willReturn(true); $descriptionAttribute->isScopable()->willReturn(true); $objectFilter->filterObject($descriptionAttribute, 'pim.internal_api.attribute.edit', ['product' => $product])->willReturn(false); $enLocale->isActivated()->willReturn(true); $localeRepository->findOneByIdentifier('en_US')->willReturn($enLocale); $objectFilter->filterObject($enLocale, 'pim.internal_api.locale.edit', ['product' => $product])->willReturn(false); $inactiveLocale->isActivated()->willReturn(false); $localeRepository->findOneByIdentifier('inactive')->willReturn($inactiveLocale); $channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel); $data = ['name' => [['locale' => 'en_US', 'scope' => 'mobile', 'value' => 'My awesome product']], 'description' => [['locale' => 'inactive', 'scope' => 'mobile', 'value' => '']]]; $this->filterCollection($data, null, ['product' => $product])->shouldReturn(['name' => [['locale' => 'en_US', 'scope' => 'mobile', 'value' => 'My awesome product']]]); }
function it_generates_completeness_indexes($namingUtility, $collection, ChannelInterface $channelWeb, ChannelInterface $channelPrint, LocaleInterface $localeFr, LocaleInterface $localeEn) { $indexes = array_fill(0, 10, 'fake_index'); $collection->getIndexInfo()->willReturn($indexes); $namingUtility->getChannels()->willReturn([$channelWeb, $channelPrint]); $channelWeb->getLocales()->willReturn([$localeEn]); $channelPrint->getLocales()->willReturn([$localeFr, $localeEn]); $channelPrint->getCode()->willReturn('PRINT'); $channelWeb->getCode()->willReturn('WEB'); $localeEn->getCode()->willReturn('en_US'); $localeFr->getCode()->willReturn('fr_FR'); $indexOptions = ['background' => true, 'w' => 0]; $collection->ensureIndex(['normalizedData.completenesses.PRINT-en_US' => 1], $indexOptions)->shouldBeCalled(); $collection->ensureIndex(['normalizedData.completenesses.PRINT-fr_FR' => 1], $indexOptions)->shouldBeCalled(); $collection->ensureIndex(['normalizedData.completenesses.WEB-en_US' => 1], $indexOptions)->shouldBeCalled(); $this->ensureCompletenessesIndexes(); }
/** * {@inheritdoc} */ public function hasLocaleSpecific(LocaleInterface $locale) { return in_array($locale->getCode(), $this->getLocaleSpecificCodes()); }
/** * Add all the values required by the given attribute * * @param AttributeInterface $attribute * @param LocaleInterface $locale */ protected function addValues(AttributeInterface $attribute, $locale) { if ($attribute->isScopable()) { foreach ($locale->getChannels() as $channel) { $key = $attribute->getCode() . '_' . $channel->getCode(); $value = $this->productBuilder->createProductValue($attribute, $locale->getCode(), $channel->getCode()); $this->productBuilder->addMissingPrices($value); $this->values[$key] = $value; } } else { $value = $this->productBuilder->createProductValue($attribute, $locale->getCode()); $this->productBuilder->addMissingPrices($value); $this->values[$attribute->getCode()] = $value; } }
/** * @param LocaleInterface $locale * @param string $field * @param mixed $data * * @throws \InvalidArgumentException */ protected function setData(LocaleInterface $locale, $field, $data) { if ('code' === $field) { $locale->setCode($data); } }
function let(UserContext $userContext, LocaleRepositoryInterface $localeRepository, LocaleInterface $en) { $en->getCode()->willReturn('en_US'); $userContext->getCurrentLocale()->willReturn($en); $this->beConstructedWith($userContext, $localeRepository); }
function it_updates_a_locale(LocaleInterface $locale) { $locale->setCode('en_US')->shouldBeCalled(); $this->update($locale, ['code' => 'en_US'], []); }
function it_throws_an_exception_when_values_data_contains_an_inactive_locale($objectFilter, $attributeRepository, $localeRepository, AttributeInterface $nameAttribute, AttributeInterface $descriptionAttribute, LocaleInterface $enLocale, LocaleInterface $inactiveLocale, ProductInterface $product) { $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute); $objectFilter->filterObject($nameAttribute, 'pim.internal_api.attribute.edit')->willReturn(false); $attributeRepository->findOneByIdentifier('description')->willReturn($descriptionAttribute); $objectFilter->filterObject($descriptionAttribute, 'pim.internal_api.attribute.edit')->willReturn(false); $enLocale->isActivated()->willReturn(true); $localeRepository->findOneByIdentifier('en_US')->willReturn($enLocale); $objectFilter->filterObject($enLocale, 'pim.internal_api.locale.edit')->willReturn(true); $inactiveLocale->isActivated()->willReturn(false); $localeRepository->findOneByIdentifier('inactive')->willReturn($inactiveLocale); $data = ['values' => ['name' => [['locale' => 'en_US', 'scope' => 'mobile', 'value' => 'My awesome product']], 'description' => [['locale' => 'inactive', 'scope' => 'mobile', 'value' => '']]]]; $this->shouldThrow('\\Pim\\Bundle\\CatalogBundle\\Exception\\ObjectNotFoundException')->during('filterCollection', [$data, null, ['product' => $product]]); }
/** * Checks if a locale is activated * * @param LocaleInterface $locale * * @return bool */ protected function isLocaleAvailable(LocaleInterface $locale) { return $locale->isActivated(); }
/** * {@inheritdoc} */ public function scheduleForChannelAndLocale(ChannelInterface $channel, LocaleInterface $locale) { $sql = <<<SQL DELETE c FROM pim_catalog_completeness c WHERE c.channel_id = :channel_id AND c.locale_id = :locale_id SQL; $sql = $this->applyTableNames($sql); $stmt = $this->connection->prepare($sql); $stmt->bindValue('channel_id', $channel->getId()); $stmt->bindValue('locale_id', $locale->getId()); $stmt->execute(); }
function it_removes_obsolete_localizable_indexes_when_locale_is_disabled($collection, LocaleInterface $en_US) { $en_US->getCode()->willReturn('en_US'); $en_US->isActivated()->willReturn(false); $collection->getIndexInfo()->willReturn([["key" => ["_id" => 1]], ["key" => ["normalizedData.title-ecommerce-en_US" => 1]], ["key" => ["normalizedData.title-ecommerce-de_DE" => 1]], ["key" => ["normalizedData.title-mobile-de_DE" => 1]], ["key" => ["normalizedData.manufacturer_title" => 1]], ["key" => ["normalizedData.title_left-en_US" => 1]], ["key" => ["normalizedData.title_left-de_DE" => 1]], ["key" => ["normalizedData.price-ecommerce.EUR.data" => 1]], ["key" => ["normalizedData.price-mobile.USD.data" => 1]], ["key" => ["normalizedData.name-mobile" => 1]], ["key" => ["normalizedData.name-ecommerce" => 1]], ["key" => ["normalizedData.mobile_support.id" => 1]], ["key" => ["normalizedData.cost-en_US.USD.data" => 1]], ["key" => ["normalizedData.color-ecommerce-en_US.id" => 1]], ["key" => ["normalizedData.completenesses-ecommerce-en_US" => 1]], ["key" => ["normalizedData.completenesses-ecommerce-de_DE" => 1]]]); $collection->deleteIndex('normalizedData.title-ecommerce-en_US')->shouldBeCalled(); $collection->deleteIndex('normalizedData.title_left-en_US')->shouldBeCalled(); $collection->deleteIndex('normalizedData.cost-en_US.USD.data')->shouldBeCalled(); $collection->deleteIndex('normalizedData.color-ecommerce-en_US.id')->shouldBeCalled(); $collection->deleteIndex('normalizedData.completenesses-ecommerce-en_US')->shouldBeCalled(); $this->purgeIndexesFromLocale($en_US); }
function it_gets_configuration($userContext, LocaleInterface $locale) { $locale->getCode()->willReturn('fr_FR'); $userContext->getUiLocale()->willReturn($locale); $this->getBatchConfig()->shouldReturn('{\\"filters\\":null,\\"actions\\":[],\\"locale\\":\\"fr_FR\\"}'); }