Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing products_type search to search for name of handler #72

Open
wants to merge 1 commit into
base: v4.0.39.ZC
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions admin/easypopulate_4_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,9 @@
}
if (!isset($filelayout['v_products_type'])) {
if ($v_artists_name <> '') {
$v_products_type = 2; // 2 = music Product - Music
$v_products_type = 'product_music'; // Change products_type to handler instead of numbers -- retched
} elseif (empty($v_products_type) && $product_is_new) {
$v_products_type = 1; // 1 = standard product @TODO Allow import of alternate product type
$v_products_type = 'product'; // Change products_type to handler instead of numbers -- retched
}
}

Expand Down Expand Up @@ -1230,7 +1230,7 @@
metatags_price_status = :metatags_price_status:,
metatags_title_tagline_status = :metatags_title_tagline_status:";
$query = $db->bindVars($query, ':products_model:', $v_products_model , $zc_support_ignore_null);
$query = $db->bindVars($query, ':products_type:', $v_products_type , 'integer');
$query = $db->bindVars($query, ':products_type:', ep4_get_product_type_handle($v_products_type) , 'integer'); // Change products_type to handler instead of numbers -- retched
$query = $db->bindVars($query, ':products_price:', $v_products_price , 'currency');
$query = $db->bindVars($query, ':products_price_uom:', (isset($v_products_price_uom) ? $v_products_price_uom : '0.00') , 'currency');
$query = $db->bindVars($query, ':products_id:', $v_products_id, 'integer');
Expand Down Expand Up @@ -1283,7 +1283,7 @@
}
$ep_import_count++;
// PRODUCT_MUSIC_EXTRA
if ($v_products_type == '2') {
if ($v_products_type == 'product_music') { // Change products_type to handler instead of numbers -- retched
$sql_music_extra = "SELECT * FROM " . TABLE_PRODUCT_MUSIC_EXTRA . " WHERE (products_id = :products_id:) LIMIT 1";
$sql_music_extra = $db->bindVars($sql_music_extra, ':products_id:', $v_products_id, 'integer');
$sql_music_extra = ep_4_query($sql_music_extra);
Expand Down Expand Up @@ -1448,7 +1448,7 @@
unset($summary);
}
// PRODUCT_MUSIC_EXTRA
if ($v_products_type == '2') {
if ($v_products_type == 'product_music') { // Change products_type to handler instead of numbers -- retched
$sql_music_extra = ep_4_query("SELECT * FROM " . TABLE_PRODUCT_MUSIC_EXTRA . " WHERE (products_id = " . (int)$v_products_id . ") LIMIT 1");
if ($ep_4_num_rows($sql_music_extra) == 1) { // update
$query = "UPDATE " . TABLE_PRODUCT_MUSIC_EXTRA . " SET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,3 +1351,16 @@ function ep4_draw_cat_list($current_cat_id, $withAttribs = true, $withProd = tru
}
return '';
}


function ep4_get_product_type_handle($str_handle) {
global $db;
// This function will change the text handle to a numeric one for insert.
// Will return 1 by default if it fails to find the type handler

$sql = "SELECT type_id FROM " . TABLE_PRODUCT_TYPES . " WHERE type_handler = :type_handler:";
$sql = $db->bindVars($sql, ':type_handler:', $str_handle , 'string');
$handler = $db->Execute($sql);

return $handler->fields['type_id'] ?? 1;
}
9 changes: 7 additions & 2 deletions admin/includes/modules/easypopulate_4_filelayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@
unset($l_id_code);
$filelayout[] = 'v_music_genre_name';
}
// Change products_type to handler instead of numbers -- retched
$filelayout_sql = 'SELECT DISTINCT

p.products_id as v_products_id,
p.products_id as v_products_id,
p.products_model as v_products_model,
p.products_type as v_products_type,
pt.type_handler as v_products_type,
p.products_image as v_products_image,
p.products_price as v_products_price,';
if ($ep_supported_mods['uom'] == true) { // price UOM mod
Expand Down Expand Up @@ -370,6 +371,10 @@
ON (
p.manufacturers_id = mi.manufacturers_id
)
LEFT JOIN ' . TABLE_PRODUCT_TYPES . ' AS pt
ON (
pt.type_id = p.products_type
)
';

$zco_notifier->notify('EP4_EXTRA_FUNCTIONS_SET_FILELAYOUT_FULL_SQL_TABLE');
Expand Down