From 03c137d204e1e61fbfa278bd6d0755c02c71fd86 Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Wed, 24 Jul 2013 15:24:51 +0200 Subject: [PATCH] ImportExport: Easier debugging Made the import more robust if import file links to a SKU which is skipped for some reasons -> leads to a "NULL" link causing fatal errors. Steps to reproduce: * Import file with SKU "1" in first line, but some errors (i.e. missing description) * In second line SKU "2", valid product data, _links_upsell_sku contains the SKU "1" --- .../ImportExport/Model/Import/Entity/Product.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/code/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/Mage/ImportExport/Model/Import/Entity/Product.php index 9cf9de8f593c9..46dc4ff9812b0 100644 --- a/app/code/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/Mage/ImportExport/Model/Import/Entity/Product.php @@ -746,6 +746,19 @@ protected function _saveLinks() } else { $linkedId = $this->_oldSku[$linkedSku]['entity_id']; } + + if ($linkedId == null) { + // Import file links to a SKU which is skipped for some reasons -> leads to a "NULL" + // link causing fatal errors. + Mage::logException( + new Exception( + sprintf('WARNING: Orphaned link skipped: From SKU %s (ID %d) to SKU %s, Link type id: %d', + $sku, $productId, $linkedSku, $linkId) + ) + ); + continue; + } + $linkKey = "{$productId}-{$linkedId}-{$linkId}"; if (!isset($linkRows[$linkKey])) {