From 697a9742ef5a3cddd0971995d6dce0ef74d9a917 Mon Sep 17 00:00:00 2001 From: mc12345678 Date: Mon, 21 Mar 2016 21:25:39 -0400 Subject: [PATCH] v4.0.34 update for priceqty import. During an import of a priceqty file, it was identified that there was a sql error if none of the fields in the products_description section were included in the import file. --- admin/easypopulate_4_import.php | 25 ++++++++++++++++++------- changelog.txt | 3 +++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/admin/easypopulate_4_import.php b/admin/easypopulate_4_import.php index 79ec804..a38e1e9 100644 --- a/admin/easypopulate_4_import.php +++ b/admin/easypopulate_4_import.php @@ -1,5 +1,5 @@ notify('EP4_IMPORT_FILE_PRODUCTS_DESCRIPTION_ADD_OR_CHANGE_DATA'); - if (isset($v_products_name) || isset($v_products_description) || ($ep_supported_mods['psd'] == true && isset($v_products_short_desc) ) || isset($v_products_url) || $add_products_description_data) { // + if ((isset($v_products_name) && is_array($v_products_name)) || (isset($v_products_description) && is_array + ($v_products_description)) || + ($ep_supported_mods['psd'] == true + && + isset + ($v_products_short_desc) ) || (isset($v_products_url) && is_array($v_products_url)) || + $add_products_description_data) { // // Effectively need a way to step through all language options, this section to be "accepted" if there is something to be updated. Prefer the ability to verify update need without having to loop on anything, but just by "presence" of information. foreach ($langcode as $lang) { // foreach ($v_products_name as $key => $name) { // Decouple the dependency on the products_name being imported to update the products_name, description, short description and/or URL. //mc12345678 2015-Dec-12 @@ -1987,7 +1993,8 @@ $sql .= ($update_count ? ", " : "") . " products_url = :v_products_url: "; $update_count = true; } - + // If using this notifier to add to the $sql, the when something is added be sure to + // set $update_count = true; $zco_notifier->notify('EP4_IMPORT_FILE_PRODUCTS_DESCRIPTION_UPDATE_FIELDS_VALUES'); $sql .= " WHERE products_id = :v_products_id: AND language_id = :language_id:"; @@ -2003,10 +2010,14 @@ $sql = $db->bindVars($sql, ':language_id:', $lang_id, 'integer'); $zco_notifier->notify('EP4_IMPORT_FILE_PRODUCTS_DESCRIPTION_FIELDS_BIND_END'); - $result = ep_4_query($sql); - if ($result) { - zen_record_admin_activity('Updated product ' . (int) $v_products_id . ' description via EP4.', 'info'); - } + // Be sure to run the update query only if there has been something provded to + // update. + if ($update_count == true) { + $result = ep_4_query($sql); + if ($result) { + zen_record_admin_activity('Updated product ' . (int)$v_products_id . ' description via EP4.', 'info'); + } + } // Perform query if there is something to update. } // END: already in description, update it } // END: foreach on languages } // END: Products Descriptions End diff --git a/changelog.txt b/changelog.txt index cd449c1..318ea94 100644 --- a/changelog.txt +++ b/changelog.txt @@ -283,3 +283,6 @@ https://www.zen-cart.com/downloads.php?do=file&id=2069 4.0.34 03/19/2016 After report of an issue with EP4.0.33 being used on ZC 1.5.5, a change was made to how paths are generated for admin side related code. + On import of priceqty files, the absence of language designated fields + now that the products description section has been rewritten + would cause a sql error on update. This has been resolved.