/**
  * Normalize the attributes
  *
  * @param AttributeGroupInterface $group
  *
  * @return array
  */
 protected function normalizeAttributes(AttributeGroupInterface $group)
 {
     $attributes = array();
     foreach ($group->getAttributes() as $attribute) {
         $attributes[] = $attribute->getCode();
     }
     return $attributes;
 }
 /**
  * Add attributes to a group
  *
  * @param AttributeGroupInterface $group
  * @param AttributeInterface[]    $attributes
  */
 public function addAttributes(AttributeGroupInterface $group, $attributes)
 {
     $maxOrder = $group->getMaxAttributeSortOrder();
     foreach ($attributes as $attribute) {
         $maxOrder++;
         $attribute->setSortOrder($maxOrder);
         $group->addAttribute($attribute);
     }
     $this->attributeSaver->saveAll($attributes);
     $this->groupSaver->save($group);
 }
 function it_add_attributes_to_attribute_group($groupSaver, $attributeSaver, AttributeGroupInterface $default, AttributeGroupInterface $group, AttributeInterface $sku, AttributeInterface $name)
 {
     $group->getMaxAttributeSortOrder()->willReturn(5);
     $sku->setSortOrder(6)->shouldBeCalled();
     $group->addAttribute($sku)->shouldBeCalled();
     $name->setSortOrder(7)->shouldBeCalled();
     $group->addAttribute($name)->shouldBeCalled();
     $attributeSaver->saveAll([$sku, $name])->shouldBeCalled();
     $groupSaver->save($group)->shouldBeCalled();
     $this->addAttributes($group, [$sku, $name]);
 }
 /**
  * Add attributes to a group
  *
  * @param AttributeGroupInterface $group
  * @param AttributeInterface[]    $attributes
  */
 public function addAttributes(AttributeGroupInterface $group, $attributes)
 {
     $maxOrder = $group->getMaxAttributeSortOrder();
     foreach ($attributes as $attribute) {
         $maxOrder++;
         $attribute->setSortOrder($maxOrder);
         $group->addAttribute($attribute);
         $this->objectManager->persist($attribute);
     }
     $this->objectManager->persist($group);
     $this->objectManager->flush();
 }
 function it_add_attributes_to_attribute_group($objectManager, AttributeGroupInterface $default, AttributeGroupInterface $group, AttributeInterface $sku, AttributeInterface $name)
 {
     $group->getMaxAttributeSortOrder()->willReturn(5);
     $sku->setSortOrder(6)->shouldBeCalled();
     $group->addAttribute($sku)->shouldBeCalled();
     $objectManager->persist($sku)->shouldBeCalled();
     $name->setSortOrder(7)->shouldBeCalled();
     $group->addAttribute($name)->shouldBeCalled();
     $objectManager->persist($name)->shouldBeCalled();
     $objectManager->persist($group)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->addAttributes($group, [$sku, $name]);
 }
 /**
  * @param AttributeGroupInterface $group
  */
 protected function initializeGroup(AttributeGroupInterface $group)
 {
     $this->view[$group->getId()] = ['label' => $group->getLabel(), 'attributes' => []];
 }
 /**
  * @param AttributeGroupInterface $group
  *
  * @Given /^I should be on the ("([^"]*)" attribute group) page$/
  */
 public function iShouldBeOnTheAttributeGroupPage(AttributeGroupInterface $group)
 {
     $expectedAddress = $this->getPage('AttributeGroup edit')->getUrl(['id' => $group->getId()]);
     $this->assertAddress($expectedAddress);
 }