Esempio n. 1
0
 /**
  * @param Attribute $attribute
  */
 public function addAttribute($attribute)
 {
     $this->title = null;
     $attribute->setVariation($this);
     $this->attributes[$attribute->getAttribute()->getId()] = $attribute;
 }
Esempio n. 2
0
 /**
  * @param Product\Attribute $attribute
  * @param Product           $product
  */
 public function addAttributes($attribute, $product)
 {
     if ($attribute instanceof Product\Attribute\Variable && $product instanceof Product\Variable) {
         /** @var $attribute Product\Attribute|Product\Attribute\Variable */
         /** @var $product Product|Product\Variable */
         if (isset($_POST['options']) && isset($_POST['options']['is_variable'])) {
             $attribute->setVariable($_POST['options']['is_variable'] === 'true');
         }
         if ($attribute->isVariable()) {
             foreach ($product->getVariations() as $variation) {
                 /** @var $variation VariableProduct\Variation */
                 if (!$variation->hasAttribute($attribute->getId())) {
                     $variableAttribute = new VariableProduct\Attribute();
                     $variableAttribute->setAttribute($attribute);
                     $variableAttribute->setVariation($variation);
                     $variation->addAttribute($variableAttribute);
                 }
             }
         }
     }
 }