
Originally Posted by
jeking
Zen Cart 1.5.7d
Easy Populate 4.0.36.ZC - 07-05-2016
Import/Export Primary Key set to products_id
We're trying to delete a bunch of products. The csv file consists of only'
v_products_id v_products_type v_products_name_1 v_categories_name_1 v_status
219273 1 Product Name 9
On import, I'm getting
NOT FOUND! - Model: 219273 - cant delete...
This site does not use model numbers for any products. I assumed setting the import/export key to products_id would have the import use the products_id and not model.
Interesting condition. I too would expect the deletion even though I know there are some changes in the latest version that might address/relate; however, when trying to review the 4.0.36ZC code:
Code:
while ($row = ($ep_uses_mysqli ? mysqli_fetch_array($result) : mysql_fetch_array($result) )) { // chadd - this executes once?? why use while-loop?? $product_is_new = false; // we found products_model in database
// Get current products descriptions and categories for this model from database
// $row at present consists of current product data for above fields only (in $sql)
// since we have a row, the item already exists.
// let's check and delete it if requested
// v_status == 9 is a delete request
$continueNextRow = false;
if ($items[$filelayout['v_status']] == 9) {
$chosen_key = '';
switch (EP4_DB_FILTER_KEY) {
case 'products_model':
$chosen_key = 'v_products_model';
break;
case 'blank_new':
case 'products_id':
$chosen_key = 'v_products_id';
break;
default:
$chosen_key = 'v_products_model';
break;
}
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_DELETED, $items[$filelayout[$chosen_key]]);
ep_4_remove_product($items[$filelayout[$chosen_key]]);
$continueNextRow = true;
}
$zco_notifier->notify('EP4_IMPORT_FILE_EARLY_ROW_PROCESSING');
if ($continueNextRow == true) {
continue 2; // short circuit - loop to next record
}
The appearance to me is that the result of the while condition is "falsey" causing that internal deletion to be skipped and leading to the message after the while loop indicating the product could not be found.
That said also, the above "file" data doesn't present what might be expected. It appears that there are only four pieces of data below the five column headers. I suspect this displayed condition is because the spreadsheet data was directly copied into this chat instead of the csv file contents. Because you are getting the error that you are, it seems one of the columns is made of non-problematic "empty" data.
It could be that the product does not have data fully across all necessary tables: Note the query.
Code:
$sql = 'SELECT p.products_id as v_products_id,
p.products_type as v_products_type,
p.products_model as v_products_model,
p.products_image as v_products_image,
p.products_price as v_products_price,';
if ($ep_supported_mods['uom'] == true) { // price UOM mod - chadd
$sql .= 'p.products_price_uom as v_products_price_uom,';
}
if ($ep_supported_mods['upc'] == true) { // UPC Code mod- chadd
$sql .= 'p.products_upc as v_products_upc,';
}
if ($ep_supported_mods['gpc'] == true) { // Google Product Category for Google Merhant Center - chadd 10-1-2011
$sql .= 'p.products_gpc as v_products_gpc,';
}
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$sql .= 'p.products_msrp as v_products_msrp,';
}
if ($ep_supported_mods['map'] == true) { // Manufacturer's Advertised Price
$sql .= 'p.map_enabled as v_map_enabled,';
$sql .= 'p.map_price as v_map_price,';
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$sql .= 'p.products_group_a_price as v_products_group_a_price,';
$sql .= 'p.products_group_b_price as v_products_group_b_price,';
$sql .= 'p.products_group_c_price as v_products_group_c_price,';
$sql .= 'p.products_group_d_price as v_products_group_d_price,';
}
if ($ep_supported_mods['excl'] == true) { // Exclusive Product Custom Mod
$sql .= 'p.products_exclusive as v_products_exclusive,';
}
$zco_notifier->notify('EP4_IMPORT_PRODUCT_DEFAULT_SELECT_FIELDS');
if (count($custom_fields) > 0) {
foreach ($custom_fields as $field) {
$sql .= 'p.' . $field . ' as v_' . $field . ',';
}
}
$sql .= 'p.products_weight as v_products_weight,
p.products_discount_type as v_products_discount_type,
p.products_discount_type_from as v_products_discount_type_from,
p.product_is_call as v_product_is_call,
p.products_sort_order as v_products_sort_order,
p.products_quantity_order_min as v_products_quantity_order_min,
p.products_quantity_order_units as v_products_quantity_order_units,
p.products_priced_by_attribute as v_products_priced_by_attribute,
p.product_is_always_free_shipping as v_product_is_always_free_shipping,
p.products_date_added as v_date_added,
p.products_date_available as v_date_avail,
p.products_tax_class_id as v_tax_class_id,
p.products_quantity as v_products_quantity,
p.products_status as v_products_status,
p.manufacturers_id as v_manufacturers_id,
p.metatags_products_name_status as v_metatags_products_name_status,
p.metatags_title_status as v_metatags_title_status,
p.metatags_model_status as v_metatags_model_status,
p.metatags_price_status as v_metatags_price_status,
p.metatags_title_tagline_status as v_metatags_title_tagline_status,
subc.categories_id as v_categories_id
FROM ' .
TABLE_PRODUCTS_TO_CATEGORIES . ' as ptoc,' .
TABLE_CATEGORIES . ' as subc,' .
TABLE_PRODUCTS . " as p ";
$zco_notifier->notify('EP4_IMPORT_PRODUCT_DEFAULT_SELECT_TABLES');
$sql .= "WHERE
p.products_id = ptoc.products_id AND
ptoc.categories_id = subc.categories_id AND ";
switch (EP4_DB_FILTER_KEY){
case 'products_model':
$sql .= "
p.products_model = :products_model:";
break;
case 'blank_new':
case 'products_id':
$sql .= "
p.products_id = :products_id:";
break;
default:
$sql .= "
p.products_model = :products_model:";
break;
}
$sql = $db->bindVars($sql, ':products_model:', $items[$filelayout['v_products_model']], 'string');
$sql = $db->bindVars($sql, ':products_id:', $items[$filelayout['v_products_id']], 'integer');
the products_to_categories table, categories and products tables are effectively all inner joined requiring a record in all three that give at least one result when queried on the products_id. So if that product isn't in the products_to_categories table or if the categories table doesn't have a match to the products_to_categories table, then the query doesn't find any results and we get the falsey value that bypasses the attempt to delete.
Can it, will it delete with that minimal amount of information, I would say yes and suggest reviewing the results of that query. May I suggest trying phpMyAdmin to run that query substituting the necessary data where it would be coded into the query. Again I suspect the result is 0 values returned and then need to figure out why.
Originally and only for information, I was going to question what filename is used; however, the response received indicates the file is being processed as an "everything else" file.
Bookmarks