コード例 #1
0
 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]);
 }
コード例 #2
0
 /**
  * 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);
 }