/** * test relatede method */ public function testAddMissingProductValues() { $builder = $this->getProductBuilder(); $product = new Product(); $this->assertEquals(count($product->getValues()), 0); $family = new Family(); $attribute = new Attribute(); $attribute->setCode('one'); $family->addAttribute($attribute); $product->setFamily($family); $builder->addMissingProductValues($product); $this->assertValues($product, array('one')); $attributeTwo = new Attribute(); $attributeTwo->setCode('two'); $attributeTwo->setLocalizable(true); $family->addAttribute($attributeTwo); $builder->addMissingProductValues($product); $this->assertValues($product, array('one', 'twoen_US', 'twofr_FR')); $attributeThree = new Attribute(); $attributeThree->setCode('three'); $attributeThree->setScopable(true); $family->addAttribute($attributeThree); $builder->addMissingProductValues($product); $this->assertValues($product, array('one', 'twoen_US', 'twofr_FR', 'threeecom', 'threeprint')); $attributeFour = new Attribute(); $attributeFour->setCode('four'); $attributeFour->setLocalizable(true); $attributeFour->setScopable(true); $family->addAttribute($attributeFour); $builder->addMissingProductValues($product); $this->assertValues($product, array('one', 'twoen_US', 'twofr_FR', 'threeecom', 'threeprint', 'fouren_USecom', 'fouren_USprint', 'fourfr_FRecom', 'fourfr_FRprint')); }
/** * {@inheritDoc} */ public function setLocalizable($localizable) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLocalizable', array($localizable)); return parent::setLocalizable($localizable); }
/** * Return the generated attributes as Attribute object * * @return array */ public function getAttributeObjects() { $attributeObjects = []; foreach ($this->attributes as $code => $attribute) { $attributeObject = new Attribute(); $attributeObject->setCode($code); $attributeObject->setAttributeType($attribute['type']); if (isset($attribute['localizable'])) { $attributeObject->setLocalizable($attribute['localizable']); } if (isset($attribute['localizable'])) { $attributeObject->setScopable($attribute['scopable']); } $attributeObjects[$code] = $attributeObject; } return $attributeObjects; }