public function process($item) { $sku = (string) $item['sku']; $attribute = $this->productManager->getIdentifierAttribute(); $product = $this->productManager->findByIdentifier($sku); // if (!$product) { // $product = $this->productManager->createProduct(); // $value = $this->productManager->createProductValue(); // $value->setAttribute($attribute); // $value->setData($sku); // $product->addValue($value); // $this->stepExecution->incrementSummaryInfo('create'); // return $product; // } else { if (!$product) { $data = current((array) $item); $this->stepExecution->incrementSummaryInfo('skip'); throw new InvalidItemException(sprintf('Skip the existing %s product', $sku), $data); } else { $product_tab = array(); $product_tab[] = $product; $this->productUpdater->setValue($product_tab, 'price', [['data' => (string) $item['price'], 'currency' => (string) $item['currency']]]); return $product; } // } }
public function process($item) { $sku = $item['sku']; $attribute = $this->productManager->getIdentifierAttribute(); $product = $this->productManager->findByIdentifier($sku); if (!$product) { $product = $this->productManager->createProduct(); $value = $this->productManager->createProductValue(); $value->setAttribute($attribute); $value->setData($sku); $product->addValue($value); $this->stepExecution->incrementSummaryInfo('create'); return $product; } else { $data = current(((array) $item)); $this->stepExecution->incrementSummaryInfo('skip'); throw new InvalidItemException(sprintf('Skip the existing %s product', $sku), $data); } }