Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $product = $this->productFactory->create();
- $type = $result[2];
- $article = $result[1];
- $size = $result[3];
- $color = $result[4];
- $qualities = isset($result[7]) ? $this->formatQualityText($result[7]) : [];
- $colorValues = isset($result[5]) ? $this->formatColorText($result[5]) : [];
- $sku = $article.'-'.$color.'-'.$size;
- $name = $article . ' - ' . $color . ' - ' . $type . ' - ' . $size;
- $price = (float) isset($result[6]) ? $result[6] : 0;
- $product->setSku($sku);
- $product->setName($name);
- $product->setPrice($price);
- if ( ! empty($colorValues)) {
- foreach($colorValues as $value) {
- $product->setCustomAttribute('nomo_color', $this->attributeHelper->createOrGetId('nomo_color', $value));
- }
- }
- if ( ! empty($color)) {
- $product->setCustomAttribute('color', $this->attributeHelper->createOrGetId('color', $color));
- }
- $this->productRepository->save($product);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement