Advertisement
Guest User

Untitled

a guest
May 24th, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. $product = $this->productFactory->create();
  2. $type = $result[2];
  3. $article = $result[1];
  4. $size = $result[3];
  5. $color = $result[4];
  6.  
  7. $qualities = isset($result[7]) ? $this->formatQualityText($result[7]) : [];
  8. $colorValues = isset($result[5]) ? $this->formatColorText($result[5]) : [];
  9.  
  10. $sku = $article.'-'.$color.'-'.$size;
  11. $name = $article . ' - ' . $color . ' - ' . $type . ' - ' . $size;
  12. $price = (float) isset($result[6]) ? $result[6] : 0;
  13.  
  14. $product->setSku($sku);
  15. $product->setName($name);
  16. $product->setPrice($price);
  17.  
  18. if ( ! empty($colorValues)) {
  19. foreach($colorValues as $value) {
  20. $product->setCustomAttribute('nomo_color', $this->attributeHelper->createOrGetId('nomo_color', $value));
  21. }
  22. }
  23.  
  24. if ( ! empty($color)) {
  25. $product->setCustomAttribute('color', $this->attributeHelper->createOrGetId('color', $color));
  26. }
  27.  
  28. $this->productRepository->save($product);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement