public function build(array $row) { if (null === $this->_unit->product) { throw new \LogicException('Base product not set for unit creation!'); } if (!$this->_validator->validateRow($row)) { throw new Exception\UploadException('Row is not valid!'); } $this->_setOptions($row); $this->_setPrices($row); $this->_setData($row); $this->_addAuthorship(); $this->_unit->visible = true; $this->_unit->stock = []; $this->_stockSetter->setStockLevel($this->_unit, $row); return $this->_unit; }
public function build(array $data) { try { if (!$this->_validator->validateRow($data)) { throw new Exception\UploadException('Row is not valid!'); } $this->_addProductType($data); $this->_addAuthorship(); $this->_addData($data); $this->_setPrices($data); return $this->_product; } catch (\Exception $e) { $this->_validator->invalidateRow($data); $key = $this->_headingKeys->getKey('name'); if (array_key_exists($key, $data)) { throw new Exception\UploadFrontEndException($e->getMessage(), 'ms.commerce.product.upload.build-fail', ['%productName%' => $data[$key], '%message%' => $e->getMessage()]); } throw $e; } }