ho-nl/Ho_Import — pull request #46 by heldchen (2014-12-30 14:02:04+00:00)
Title: Set non-zero exit code when an error happened

This lets executing scripts determine if the import failed.

#### before patch:
```
...
2014-12-30 13:57:30 IMPORT: PIM products: start
...
13:58:01 - 178MB Setting option action to import
13:58:01 - 178MB Setting option profile to pim_import_products_full
13:58:01 - 178MB Successfully turned off automatic indexing
13:58:01 - 178MB Start import catalog_product
14:07:54 - 251MB Exception while running profile pim_import_products_full, ran for 593.42 seconds.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'p-02051093-5-salomon-ellipse-aero' for key 'UNQ_CATALOG_PRODUCT_ENTITY_URL_KEY_VALUE', query was: INSERT INTO `catalog_product_entity_url_key` (`entity_id`,`entity_type_id`,`attribute_id`,`store_id`,`value`) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)

#0 /var/www/users/magento/src/www/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/users/magento/src/www/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/users/magento/src/www/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/users/magento/src/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /var/www/users/magento/src/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /var/www/users/magento/src/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(1934): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...', Array)
#6 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php(890): Varien_Db_Adapter_Pdo_Mysql->insertOnDuplicate('catalog_product...', Array, Array)
#7 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php(1055): AvS_FastSimpleImport_Model_Import_Entity_Product->_saveProductAttributes(Array)
#8 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php(481): AvS_FastSimpleImport_Model_Import_Entity_Product->_saveProducts()
#9 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php(522): Mage_ImportExport_Model_Import_Entity_Product->_importData()
#10 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import.php(325): Mage_ImportExport_Model_Import_Entity_Abstract->importData()
#11 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import.php(111): Mage_ImportExport_Model_Import->importSource()
#12 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(648): AvS_FastSimpleImport_Model_Import->processProductImport('/var/www/users/...')
#13 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(429): Ho_Import_Model_Import->_importData()
#14 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(452): Ho_Import_Model_Import->_importMain('catalog_product')
#15 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(97): Ho_Import_Model_Import->_importCatalogProduct()
#16 /var/www/users/magento/src/www/shell/hoimport.php(39): Ho_Import_Model_Import->process()
#17 /var/www/users/magento/src/www/shell/hoimport.php(45): Ho_Import_Model_Import->importAction()
#18 /var/www/users/magento/src/www/shell/hoimport.php(116): Ho_Import_Shell_Productimport->run()
#19 {main}

2014-12-30 14:07:55 IMPORT: PIM products: end
2014-12-30 14:07:55 IMPORT: ERP products: start
14:07:55 - 11MB Setting option partial_indexing to 0
14:07:55 - 11MB Setting option continue_after_errors to 1
...
```

#### after patch:
```
...
2014-12-30 14:34:50 IMPORT: PIM products: start
...
14:35:22 - 178MB Setting option action to import
14:35:22 - 178MB Setting option profile to pim_import_products_full
14:35:22 - 178MB Successfully turned off automatic indexing
14:35:22 - 178MB Start import catalog_product
14:45:23 - 250MB Exception while running profile pim_import_products_full, ran for 600.64 seconds.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'p-02051093-5-salomon-ellipse-aero' for key 'UNQ_CATALOG_PRODUCT_ENTITY_URL_KEY_VALUE', query was: INSERT INTO `catalog_product_entity_url_key` (`entity_id`,`entity_type_id`,`attribute_id`,`store_id`,`value`) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)

#0 /var/www/users/magento/src/www/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/users/magento/src/www/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/users/magento/src/www/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/users/magento/src/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /var/www/users/magento/src/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /var/www/users/magento/src/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(1934): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...', Array)
#6 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php(890): Varien_Db_Adapter_Pdo_Mysql->insertOnDuplicate('catalog_product...', Array, Array)
#7 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Product.php(1055): AvS_FastSimpleImport_Model_Import_Entity_Product->_saveProductAttributes(Array)
#8 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php(481): AvS_FastSimpleImport_Model_Import_Entity_Product->_saveProducts()
#9 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php(522): Mage_ImportExport_Model_Import_Entity_Product->_importData()
#10 /var/www/users/magento/src/www/app/code/core/Mage/ImportExport/Model/Import.php(325): Mage_ImportExport_Model_Import_Entity_Abstract->importData()
#11 /var/www/users/magento/src/www/app/code/community/AvS/FastSimpleImport/Model/Import.php(111): Mage_ImportExport_Model_Import->importSource()
#12 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(648): AvS_FastSimpleImport_Model_Import->processProductImport('/var/www/users/...')
#13 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(429): Ho_Import_Model_Import->_importData()
#14 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(452): Ho_Import_Model_Import->_importMain('catalog_product')
#15 /var/www/users/magento/src/www/app/code/community/Ho/Import/Model/Import.php(97): Ho_Import_Model_Import->_importCatalogProduct()
#16 /var/www/users/magento/src/www/shell/hoimport.php(39): Ho_Import_Model_Import->process()
#17 /var/www/users/magento/src/www/shell/hoimport.php(45): Ho_Import_Model_Import->importAction()
#18 /var/www/users/magento/src/www/shell/hoimport.php(116): Ho_Import_Shell_Productimport->run()
#19 {main}

ERROR: importing PIM products failed with an error
```