/**
  * Checks if the given completeness is in the given channel.
  *
  * @param AbstractCompleteness $completeness
  * @param Channel              $channel
  *
  * @return bool
  */
 protected function isInChannel(AbstractCompleteness $completeness, Channel $channel)
 {
     if ($completeness->getChannel()->getId() === $channel->getId()) {
         return true;
     }
     return false;
 }
 /**
  * Create a channel
  * @param string $code
  *
  * @return \Pim\Bundle\CatalogBundle\Entity\Channel
  */
 protected function createChannel($code)
 {
     $channel = new Channel();
     $channel->setCode($code);
     $channel->setLabel(ucfirst($code));
     return $channel;
 }
 /**
  * {@inheritdoc}
  *
  * @return Family
  */
 protected function createEntity(array $data)
 {
     $family = new Family();
     $family->setCode('mycode');
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $family->getTranslation($locale);
         $translation->setLabel($label);
         $family->addTranslation($translation);
     }
     $codes = array('attribute1', 'attribute2', 'attribute3');
     $attributes = array();
     foreach ($codes as $code) {
         $attribute = new Attribute();
         $attribute->setCode($code);
         $family->addAttribute($attribute);
         $attributes[] = $attribute;
     }
     $family->setAttributeAsLabel(current($attributes));
     $channel1 = new Channel();
     $channel1->setCode('channel1');
     $channel2 = new Channel();
     $channel2->setCode('channel2');
     $requirements = array(array('attribute' => $attributes[0], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel1, 'required' => true), array('attribute' => $attributes[2], 'channel' => $channel1, 'required' => false), array('attribute' => $attributes[0], 'channel' => $channel2, 'required' => true), array('attribute' => $attributes[1], 'channel' => $channel2, 'required' => false), array('attribute' => $attributes[2], 'channel' => $channel2, 'required' => true));
     $attrRequirements = array();
     foreach ($requirements as $requirement) {
         $attrRequirement = new AttributeRequirement();
         $attrRequirement->setAttribute($requirement['attribute']);
         $attrRequirement->setChannel($requirement['channel']);
         $attrRequirement->setRequired($requirement['required']);
         $attrRequirements[] = $attrRequirement;
     }
     $family->setAttributeRequirements($attrRequirements);
     return $family;
 }
 function let(DocumentManager $manager, Channel $ecommerce, Channel $mobile, Locale $enUs, Locale $frFr, CategoryInterface $category, ChannelManager $channelManager, CategoryRepository $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_converts_metric_values_given_the_configured_base_unit_in_the_channel($converter, AbstractProductValue $weightValue, AbstractProductValue $surfaceValue, AbstractProductValue $nameValue, AbstractAttribute $weight, AbstractAttribute $surface, AbstractAttribute $name, AbstractMetric $weightMetric, AbstractMetric $surfaceMetric, ProductInterface $product, Channel $channel)
 {
     $weightValue->getAttribute()->willReturn($weight);
     $weightValue->getData()->willReturn($weightMetric);
     $weight->getCode()->willReturn('weight');
     $weightMetric->getFamily()->willReturn('Weight');
     $weightMetric->getUnit()->willReturn('KILOGRAM');
     $weightMetric->getData()->willReturn(1);
     $surfaceValue->getAttribute()->willReturn($surface);
     $surfaceValue->getData()->willReturn($surfaceMetric);
     $surface->getCode()->willReturn('surface');
     $surfaceMetric->getFamily()->willReturn('Surface');
     $surfaceMetric->getUnit()->willReturn('METER_SQUARE');
     $surfaceMetric->getData()->willReturn(10);
     $nameValue->getAttribute()->willReturn($name);
     $nameValue->getData()->willReturn('foobar');
     $product->getValues()->willReturn(array($weightValue, $surfaceValue, $nameValue));
     $channel->getConversionUnits()->willReturn(array('weight' => 'GRAM'));
     $converter->setFamily('Weight')->shouldBeCalled();
     $converter->convert('KILOGRAM', 'GRAM', 1)->willReturn(0.001);
     $converter->setFamily('Surface')->shouldNotBeCalled();
     $weightMetric->setData(0.001)->shouldBeCalled();
     $weightMetric->setUnit('GRAM')->shouldBeCalled();
     $this->convert($product, $channel);
 }
 /**
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getChannelManagerMock()
 {
     $channel = new Channel();
     $channel->setCode('mobile');
     $mock = $this->getMockBuilder('Pim\\Bundle\\CatalogBundle\\Manager\\ChannelManager')->disableOriginalConstructor()->getMock();
     $mock->expects($this->any())->method('getChannelByCode')->will($this->returnValue($channel));
     return $mock;
 }
 function it_normalizes_completeness(Completeness $completeness, Channel $channel, Locale $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_generates_a_query_to_update_product_scopable_attributes($namingUtility, AbstractAttribute $label, Channel $mobile)
 {
     $namingUtility->getScopableAttributes(false)->willReturn([$label]);
     $label->getCode()->willReturn('label');
     $namingUtility->getLocaleCodes()->willReturn(['fr_FR', 'en_US']);
     $namingUtility->appendSuffixes(['normalizedData.label'], ['fr_FR', 'en_US'])->willReturn(['normalizedData.label-fr_FR', 'normalizedData.label-en_US']);
     $namingUtility->appendSuffixes(['normalizedData.label-fr_FR', 'normalizedData.label-en_US'], ['mobile'])->willReturn(['normalizedData.label-fr_FR-mobile', 'normalizedData.label-en_US-mobile']);
     $mobile->getCode()->willReturn('mobile');
     $this->generateQuery($mobile, '', '', '')->shouldReturn([[['normalizedData.label-fr_FR-mobile' => ['$exists' => true]], ['$unset' => ['normalizedData.label-fr_FR-mobile' => '']], ['multiple' => true]], [['normalizedData.label-en_US-mobile' => ['$exists' => true]], ['$unset' => ['normalizedData.label-en_US-mobile' => '']], ['multiple' => true]]]);
 }
 /**
  * Is the given product complete for the given channel?
  *
  * @param ProductInterface $product
  * @param Channel          $channel
  *
  * @return bool
  */
 protected function isProductComplete(ProductInterface $product, Channel $channel)
 {
     $completenesses = $product->getCompletenesses()->toArray();
     foreach ($completenesses as $completeness) {
         if ($completeness->getChannel()->getId() === $channel->getId() && $completeness->getRatio() === 100) {
             return true;
         }
     }
     return false;
 }
 /**
  * Convert all the products metric values into the channel configured conversion units
  *
  * @param ProductInterface $product
  * @param Channel          $channel
  */
 public function convert(ProductInterface $product, Channel $channel)
 {
     $channelUnits = $channel->getConversionUnits();
     foreach ($product->getValues() as $value) {
         $data = $value->getData();
         $attribute = $value->getAttribute();
         if ($data instanceof AbstractMetric && isset($channelUnits[$attribute->getCode()])) {
             $channelUnit = $channelUnits[$attribute->getCode()];
             $this->converter->setFamily($data->getFamily());
             $data->setData($this->converter->convert($data->getUnit(), $channelUnit, $data->getData()));
             $data->setUnit($channelUnit);
         }
     }
 }
    /**
     * Get the deleted locales of a channel (the channel is updated but not flushed yet).
     *
     * @param Channel $channel
     *
     * @return array the list of deleted locales
     */
    public function getDeletedLocalesForChannel(Channel $channel)
    {
        $currentLocaleIds = array_map(function ($locale) {
            return $locale->getId();
        }, $channel->getLocales()->toArray());
        $dql = <<<DQL
            SELECT l
            JOIN l.channels c
            WHERE c.id = :channel_id
              AND l.id NOT IN (:current_locale_ids)
DQL;
        $query = $this->getEntityManager()->createQuery($dql)->setParameter(':channel_id', $channel->getId())->setParameter(':current_locale_ids', implode(',', $currentLocaleIds));
        return $query->getResult();
    }
 /**
  * {@inheritdoc}
  */
 public function buildByChannelAndCompleteness(Channel $channel)
 {
     $scope = $channel->getCode();
     $qb = $this->buildByScope($scope);
     $rootAlias = $qb->getRootAlias();
     $expression = 'pCompleteness.product = ' . $rootAlias . ' AND ' . $qb->expr()->eq('pCompleteness.ratio', '100') . ' AND ' . $qb->expr()->eq('pCompleteness.channel', $channel->getId());
     $rootEntity = current($qb->getRootEntities());
     $completenessMapping = $this->_em->getClassMetadata($rootEntity)->getAssociationMapping('completenesses');
     $completenessClass = $completenessMapping['targetEntity'];
     $qb->innerJoin($completenessClass, 'pCompleteness', 'WITH', $expression);
     $treeId = $channel->getCategory()->getId();
     $expression = $qb->expr()->eq('pCategory.root', $treeId);
     $qb->innerJoin($rootAlias . '.categories', 'pCategory', 'WITH', $expression);
     return $qb;
 }
    /**
     * Get the deleted locales of a channel (the channel is updated but not flushed yet).
     *
     * @param Channel $channel
     *
     * @return array the list of deleted locales
     */
    public function getDeletedLocaleIdsForChannel(Channel $channel)
    {
        $currentLocaleIds = array_map(function ($locale) {
            return $locale->getId();
        }, $channel->getLocales()->toArray());
        $sql = <<<SQL
    SELECT cl.locale_id
    FROM pim_catalog_channel_locale cl
    WHERE cl.channel_id = :channel_id
      AND cl.locale_id NOT IN (:current_locale_ids)
SQL;
        $stmt = $this->getEntityManager()->getConnection()->executeQuery($sql, array(':channel_id' => $channel->getId(), ':current_locale_ids' => $currentLocaleIds), array(':current_locale_ids' => Connection::PARAM_INT_ARRAY));
        $rows = $stmt->fetchAll();
        $locales = array_map(function ($row) {
            return (int) $row['locale_id'];
        }, $rows);
        return $locales;
    }
 function it_returns_only_products_in_the_given_channel(ProductInterface $product1, ProductInterface $product2, Channel $channel, ArrayCollection $productCategories1, ArrayCollection $productCategories2, ArrayCollection $completenesses, Category $rootCategory, Category $category1, Category $category2, AbstractCompleteness $completeness1, AbstractCompleteness $completeness2)
 {
     $channel->getCategory()->willReturn($rootCategory);
     $channel->getId()->willReturn(2);
     $rootCategory->getId()->willReturn(1);
     $product1->getCategories()->willReturn($productCategories1);
     $product2->getCategories()->willReturn($productCategories2);
     $product1->getCompletenesses()->willReturn($completenesses);
     $product2->getCompletenesses()->willReturn($completenesses);
     $completenesses->toArray()->willReturn([$completeness1, $completeness2]);
     $completeness1->getChannel()->willReturn($channel);
     $completeness2->getChannel()->willReturn($channel);
     $completeness1->getRatio()->willReturn(100);
     $completeness2->getRatio()->willReturn(100);
     $productCategories1->toArray()->willReturn([$category1]);
     $productCategories2->toArray()->willReturn([$category2]);
     $category1->getRoot()->willReturn(1);
     $category2->getRoot()->willReturn(5);
     $this->apply($channel, [$product1, $product2])->shouldReturn([$product1]);
 }
 /**
  * Test related method
  */
 public function testLocaleActivation()
 {
     $locale1 = $this->createLocale('en_US');
     $locale2 = $this->createLocale('fr_FR');
     $this->channel->addLocale($locale1);
     $this->channel->addLocale($locale2);
     $this->assertTrue($locale1->isActivated());
     $this->assertTrue($locale2->isActivated());
     $this->channel->removeLocale($locale1);
     $this->channel->removeLocale($locale2);
     $this->assertFalse($locale1->isActivated());
     $this->assertFalse($locale2->isActivated());
 }
 function it_generates_localizable_indexes_when_saving_enabled_locale($collection, $namingUtility, AbstractAttribute $description, Locale $en_US, Locale $de_DE, Channel $ecommerce)
 {
     $description->getCode()->willReturn('description');
     $description->getBackendType()->willReturn('varchar');
     $description->isLocalizable()->willReturn(true);
     $description->isScopable()->willReturn(false);
     $description->isUseableAsGridFilter()->willReturn(true);
     $description->getAttributeType()->willReturn('pim_catalog_text');
     $en_US->getCode()->willReturn('en_US');
     $en_US->isActivated()->willReturn(true);
     $de_DE->getCode()->willReturn('de_DE');
     $de_DE->isActivated()->willReturn(true);
     $ecommerce->getCode()->willReturn('ecommerce');
     $ecommerce->getLocales()->willReturn([$en_US, $de_DE]);
     $namingUtility->getChannels()->willReturn([$ecommerce]);
     $namingUtility->getLocalizableAttributes()->willReturn([$description]);
     $namingUtility->getAttributeNormFields($description)->willReturn(['normalizedData.description-en_US', 'normalizedData.description-de_DE']);
     $options = ['background' => true, 'w' => 0];
     $collection->ensureIndex(['normalizedData.completenesses.ecommerce-en_US' => 1], $options)->shouldBeCalled();
     $collection->ensureIndex(['normalizedData.completenesses.ecommerce-de_DE' => 1], $options)->shouldBeCalled();
     $collection->ensureIndex(['normalizedData.description-en_US' => 1], $options)->shouldBeCalled();
     $collection->ensureIndex(['normalizedData.description-de_DE' => 1], $options)->shouldBeCalled();
     $this->ensureIndexesFromLocale($en_US);
 }
 /**
  * {@inheritdoc}
  *
  * @return Channel
  */
 protected function createEntity(array $data)
 {
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($data['currencies'] as $currencyCode) {
         $currency = $this->createCurrency($currencyCode);
         $channel->addCurrency($currency);
     }
     foreach ($data['locales'] as $localeCode) {
         $locale = $this->createLocale($localeCode);
         $channel->addLocale($locale);
     }
     $category = $this->createCategory($data['category']);
     $channel->setCategory($category);
     $channel->setConversionUnits(array('weight' => 'KILOGRAM', 'washing_temperature' => null));
     return $channel;
 }
 /**
  * Apply complete filter
  *
  * @param ProductQueryBuilder $pqb
  * @param Channel             $channel
  */
 protected function applyCompleteFilter(ProductQueryBuilder $pqb, Channel $channel)
 {
     switch ($this->completeCondition) {
         case "onlyComplete":
             $pqb->addFilter('completeness_for_export', '=', 100, ['scope' => $channel->getCode()]);
             break;
         case "onlyUncomplete":
             $pqb->addFilter('completeness_for_export', '<', 100, ['scope' => $channel->getCode()]);
             break;
     }
 }
 /**
  * @return array
  */
 protected function getChannels()
 {
     $codes = array('ecom', 'print');
     $channels = array();
     foreach ($codes as $code) {
         $channel = new Channel();
         $channel->setCode($code);
         foreach ($this->getLocales() as $locale) {
             $channel->addLocale($locale);
         }
         $channels[] = $channel;
     }
     return $channels;
 }
 /**
  * Returns conversion units
  *
  * @param Channel $channel
  *
  * @return array
  */
 protected function normalizeConversionUnits(Channel $channel)
 {
     $result = array();
     foreach ($channel->getConversionUnits() as $family => $unit) {
         $result[] = sprintf('%s: %s', $family, $unit);
     }
     return implode(', ', $result);
 }
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'color' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     if ($data['color']) {
         $channel->setColor($data['color']);
     }
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency($currencyCode));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale($localeCode));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->persist($channel);
 }
 function it_removes_obsolete_scopable_indexes_when_channel_removed($collection, Channel $ecommerce)
 {
     $ecommerce->getCode()->willReturn('ecommerce');
     $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.color-ecommerce.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-ecommerce-de_DE')->shouldBeCalled();
     $collection->deleteIndex('normalizedData.price-ecommerce.EUR.data')->shouldBeCalled();
     $collection->deleteIndex('normalizedData.name-ecommerce')->shouldBeCalled();
     $collection->deleteIndex('normalizedData.color-ecommerce.id')->shouldBeCalled();
     $collection->deleteIndex('normalizedData.completenesses-ecommerce-en_US')->shouldBeCalled();
     $collection->deleteIndex('normalizedData.completenesses-ecommerce-de_DE')->shouldBeCalled();
     $this->purgeIndexesFromChannel($ecommerce);
 }
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency(['code' => explode(',', $currencyCode)]));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale(['code' => explode(',', $localeCode)]));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->getContainer()->get('pim_catalog.saver.channel')->save($channel);
 }
 /**
  * Remove indexes associated with the provided channel
  *
  * @param Channel $channel
  */
 public function purgeIndexesFromChannel(Channel $channel)
 {
     $channelPattern = sprintf('/^%s\\..+-%s/', ProductQueryUtility::NORMALIZED_FIELD, $channel->getCode());
     $indexesToRemove = $this->getIndexesMatching($channelPattern);
     $this->removeIndexes($indexesToRemove);
 }
 function getChannel()
 {
     $channel = new Channel();
     $channel->setCode('catalog');
     $currency = new Currency();
     $currency->setCode('EUR');
     $channel->addCurrency($currency);
     return $channel;
 }
 /**
  * {@inheritdoc}
  */
 public function buildByChannelAndCompleteness(Channel $channel)
 {
     $qb = $this->createQueryBuilder('p');
     foreach ($channel->getLocales() as $locale) {
         $qb->addOr($qb->expr()->field(sprintf('normalizedData.completenesses.%s-%s', $channel->getCode(), $locale->getCode()))->equals(100));
     }
     $categoryIds = $this->categoryRepository->getAllChildrenIds($channel->getCategory());
     $qb->addAnd($qb->expr()->field('categoryIds')->in($categoryIds));
     return $qb;
 }
 /**
  * Get the completeness fields for the channel
  *
  * @param Channel $channel
  *
  * @return array
  */
 protected function getCompletenessNormFields(Channel $channel = null)
 {
     $normFields = [];
     $channels = [];
     if (null === $channel) {
         $channels = $this->namingUtility->getChannels();
     } else {
         $channels[] = $channel;
     }
     foreach ($channels as $channel) {
         foreach ($channel->getLocales() as $locale) {
             $normFields[] = sprintf('%s.completenesses.%s-%s', ProductQueryUtility::NORMALIZED_FIELD, $channel->getCode(), $locale->getCode());
         }
     }
     return $normFields;
 }
 /**
  * Schedule recalculation of completenesses for all products
  * of a channel
  *
  * @param Channel $channel
  */
 public function scheduleForChannel(Channel $channel)
 {
     if ($channel->getId()) {
         $deletedLocaleIds = $this->channelRepository->getDeletedLocaleIdsForChannel($channel);
         foreach ($deletedLocaleIds as $deletedLocaleId) {
             $deletedLocale = $this->localeRepository->find($deletedLocaleId);
             $this->generator->scheduleForChannelAndLocale($channel, $deletedLocale);
         }
     }
 }
 /**
  * Remove channel
  *
  * @param Request $request
  * @param Channel $channel
  *
  * @AclAncestor("pim_enrich_channel_remove")
  * @return Response
  */
 public function removeAction(Request $request, Channel $channel)
 {
     $channelCount = $this->getRepository('PimCatalogBundle:Channel')->countAll();
     if ($channelCount <= 1) {
         throw new DeleteException($this->getTranslator()->trans('flash.channel.not removable'));
     }
     foreach ($channel->getLocales() as $locale) {
         $locale->removeChannel($channel);
     }
     $this->channelRemover->remove($channel);
     if ($request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirect($this->generateUrl('pim_enrich_channel_index'));
     }
 }
 /**
  * Update catalog scope of users using a channel that will be removed
  *
  * @param Channel $channel
  *
  * @return null
  */
 protected function onChannelRemoved(Channel $channel)
 {
     $users = $this->findUsersBy(array('catalogScope' => $channel));
     $scopes = $this->container->get('pim_catalog.manager.channel')->getChannels();
     $defaultScope = current(array_filter($scopes, function ($scope) use($channel) {
         return $scope->getCode() !== $channel->getCode();
     }));
     foreach ($users as $user) {
         $user->setCatalogScope($defaultScope);
         $this->computeChangeset($user);
     }
 }