/** * Test getter for attribute ids */ public function testGetAttributeIds() { $expectedIds = array(1, 4, 6); foreach ($expectedIds as $id) { $attribute = new Attribute(); $attribute->setId($id); $this->group->addAttribute($attribute); } $this->assertEquals($expectedIds, $this->group->getAttributeIds()); }
/** * {@inheritdoc} * * @return Group */ protected function createEntity(array $data) { $group = new Group(); $group->setCode($data['code']); $type = new GroupType(); $type->setCode($data['type']); $type->setVariant($data['type'] === 'VARIANT'); $group->setType($type); foreach ($this->getLabels($data) as $locale => $label) { $translation = $group->getTranslation($locale); $translation->setLabel($label); $group->addTranslation($translation); } foreach ($this->getAttributes($data) as $attribute) { $group->addAttribute($attribute); } return $group; }
/** * @param string $code * @param string $label * @param string $type * @param array $attributes * @param array $products */ protected function createProductGroup($code, $label, $type, array $attributes, array $products = []) { $group = new Group(); $group->setCode($code); $group->setLocale('en_US')->setLabel($label); // TODO translation refactoring $type = $this->getGroupType($type); $group->setType($type); foreach ($attributes as $attributeCode) { $attribute = $this->getAttribute($attributeCode); $group->addAttribute($attribute); } // TODO replace by call to a saver $this->validate($group); $this->persist($group); $this->flush($group); foreach ($products as $sku) { if (!empty($sku)) { $product = $this->getProduct($sku); $product->addGroup($group); $this->validate($product); $this->getProductSaver()->save($product); } } }
/** * {@inheritDoc} */ public function addAttribute(\Pim\Bundle\CatalogBundle\Model\AttributeInterface $attribute) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addAttribute', array($attribute)); return parent::addAttribute($attribute); }