Skip to content

Commit

Permalink
Merge pull request #32 from WeareJH/bugs/product-exception
Browse files Browse the repository at this point in the history
Throwing exception if product not found
  • Loading branch information
AydinHassan committed Dec 9, 2015
2 parents 0c892da + abbeb7f commit feb8ad9
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Jh\DataImportMagento\Writer\Product;

use Ddeboer\DataImport\Exception\WriterException;
use Ddeboer\DataImport\Writer\AbstractWriter;
use Jh\DataImportMagento\Exception\MagentoSaveException;

Expand Down Expand Up @@ -33,9 +34,11 @@ public function __construct(\Mage_Catalog_Model_Product $productModel)
public function writeItem(array $item)
{
$productModel = clone $this->productModel;
$product = $productModel->loadByAttribute('sku', $item['sku']);
$sku = $item['sku'];
$product = $productModel->loadByAttribute('sku', $sku);

if (!$product) {
return;
throw new WriterException(sprintf('Product with SKU: %s does not exist in Magento', $sku));
}

$product->addData($item);
Expand Down

0 comments on commit feb8ad9

Please sign in to comment.