Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function writeItem(array $item) |
||
35 | { |
||
36 | $productModel = clone $this->productModel; |
||
37 | $sku = $item['sku']; |
||
38 | $product = $productModel->loadByAttribute('sku', $sku); |
||
39 | |||
40 | if (!$product) { |
||
41 | throw new WriterException(sprintf('Product with SKU: %s does not exist in Magento', $sku)); |
||
42 | } |
||
43 | |||
44 | $product->addData($item); |
||
45 | |||
46 | try { |
||
47 | $product->save(); |
||
48 | } catch (\Mage_Core_Exception $e) { |
||
49 | $message = $e->getMessage(); |
||
50 | throw new MagentoSaveException($message); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 |