Ejemplo n.º 1
0
 function it_provides_formatted_batch_config_for_the_job(CategoryInterface $officeCategory, CategoryInterface $bedroomCategory)
 {
     $officeCategory->getCode()->willReturn('office_room');
     $bedroomCategory->getCode()->willReturn('bedroom');
     $this->setCategories([$officeCategory, $bedroomCategory]);
     $this->setFilters([['id', 'IN', ['49', '2']]]);
     $this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"49\\",\\"2\\"]]],\\"actions\\":[{\\"field\\":\\"categories\\",\\"value\\":[\\"office_room\\",\\"bedroom\\"]}]}');
 }
Ejemplo n.º 2
0
 function it_provides_formatted_batch_config_for_the_job(CategoryInterface $officeCategory, CategoryInterface $bedroomCategory)
 {
     $officeCategory->getCode()->willReturn('office_room');
     $bedroomCategory->getCode()->willReturn('bedroom');
     $this->setCategories([$officeCategory, $bedroomCategory]);
     $this->setFilters([['id', 'IN', ['49', '2']]]);
     $this->getBatchConfig()->shouldReturn(['filters' => [['id', 'IN', ['49', '2']]], 'actions' => [['field' => 'categories', 'value' => ['office_room', 'bedroom']]]]);
 }
 /**
  * Update default tree of users using a tree that will be removed
  *
  * @param CategoryInterface $category
  */
 protected function onTreeRemoved(CategoryInterface $category)
 {
     $users = $this->findUsersBy(['defaultTree' => $category]);
     $trees = $this->container->get('pim_catalog.repository.category')->getTrees();
     $defaultTree = current(array_filter($trees, function ($tree) use($category) {
         return $tree->getCode() !== $category->getCode();
     }));
     foreach ($users as $user) {
         $user->setDefaultTree($defaultTree);
         $this->computeChangeset($user);
     }
 }