function it_adds_product_value(ProductInterface $product, AttributeInterface $size)
 {
     $size->isLocalizable()->willReturn(false);
     $size->isScopable()->willReturn(false);
     $product->addValue(Argument::any())->shouldBeCalled();
     $this->addProductValue($product, $size);
 }
 /**
  * @param ProductManager   $manager    the product manager
  * @param ProductInterface $product    the entity
  * @param array            $attributes the attributes
  */
 protected function addValues(ProductManager $manager, ProductInterface $product, $attributes)
 {
     foreach ($attributes as $attribute) {
         $value = $manager->createProductValue();
         $value->setAttribute($attribute);
         $product->addValue($value);
     }
 }
 /**
  * @param ProductManager   $manager    the product manager
  * @param ProductInterface $product    the entity
  * @param array            $attributes the attributes
  */
 protected function addValues(ProductManager $manager, ProductInterface $product, $attributes)
 {
     foreach ($attributes as $attribute) {
         $value = $manager->createProductValue();
         $value->setAttribute($attribute);
         if ($attribute->getDefaultValue() !== null) {
             $value->setData($attribute->getDefaultValue());
         }
         $product->addValue($value);
     }
 }
 /**
  * Returns a ProductValue
  *
  * @param ProductInterface    $product
  * @param ColumnInfoInterface $columnInfo
  *
  * @return ProductValueInterface
  */
 protected function getProductValue(ProductInterface $product, ColumnInfoInterface $columnInfo)
 {
     $productValue = $product->getValue($columnInfo->getName(), $columnInfo->getLocale(), $columnInfo->getScope());
     if (null === $productValue) {
         $productValue = $this->productManager->createProductValue();
         $productValue->setAttribute($columnInfo->getAttribute());
         $productValue->setLocale($columnInfo->getLocale());
         $productValue->setScope($columnInfo->getScope());
         $product->addValue($productValue);
     }
     return $productValue;
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function addProductValue(ProductInterface $product, AttributeInterface $attribute, $locale = null, $scope = null)
 {
     $value = $this->createProductValue($attribute, $locale, $scope);
     $product->addValue($value);
     return $value;
 }
 /**
  * Add a missing value to the product
  *
  * @param ProductInterface  $product
  * @param AbstractAttribute $attribute
  * @param string            $locale
  * @param string            $scope
  *
  * @return ProductValueInterface
  */
 public function addProductValue(ProductInterface $product, AbstractAttribute $attribute, $locale = null, $scope = null)
 {
     $value = $this->createProductValue();
     if ($locale) {
         $value->setLocale($locale);
     }
     $value->setScope($scope);
     $value->setAttribute($attribute);
     $product->addValue($value);
     return $value;
 }