A few days ago I posted a question about how to add a new field to be included for uploading and downloading. After quite a bit of looking through the main file, testing and printing variables, I have been able to get my extra field added both to the download as well as uploading. I thought other might be interested in how I did this.
First a few caveats:
- I was only concerned with the Complete upload/download (and only made mods to those parts of the file)
- The field I needed to add is an added field to the products_descriptions table. If you need to add a field from another table, this might or might not help you.
- Line numbers given are approximate (yours may differ slightly).
Line 360
** Original:**
$filelayout = array_merge($filelayout , array(
'v_products_name_' . $l_id => $iii++,
'v_products_description_' . $l_id => $iii++,
));
** Changed to:**
$filelayout = array_merge($filelayout , array(
'v_products_name_' . $l_id => $iii++,
'v_new_field_' . $l_id => $iii++,
'v_products_description_' . $l_id => $iii++,
));
Line 791
** Original:**
$row['v_products_name_' . $lid] = $row2['products_name'];
$row['v_products_description_' . $lid] = $row2['products_description'];
if ($ep_supported_mods['psd'] == true) {
$row['v_products_short_desc_' . $lid] = $row2['products_short_desc'];
}
** Changed to:**
$row['v_products_name_' . $lid] = $row2['products_name'];
$row['v_products_description_' . $lid] = $row2['products_description'];
$row['v_new_field_' . $lid] = $row2['new_field'];
if ($ep_supported_mods['psd'] == true) {
$row['v_products_short_desc_' . $lid] = $row2['products_short_desc'];
}
Line 1280
** Original:**
$default_these = array(
'v_products_image',
// redundant image mods removed
'v_categories_id',
[...]
'v_products_width',
'v_products_height'
);
** Changed to:**
$default_these = array(
'v_products_image',
// redundant image mods removed
'v_categories_id',
[...]
'v_products_width',
'v_products_height',
'v_new_field'
);
Line 1484
** Original:**
// Need to report from ......name_1 not ...name_0
$row['v_products_name' . $lang['id']] = $row2['products_name'];// name assigned
$row['v_products_description' . $lang['id']] = $row2['products_description'];// description assigned
** Changed to:**
// Need to report from ......name_1 not ...name_0
$row['v_products_name' . $lang['id']] = $row2['products_name'];// name assigned
$row['v_products_description' . $lang['id']] = $row2['products_description'];// description assigned
$row['v_new_field_' . $lang['id']] = $row2['new_field'];
Line 1660
** Original:**
foreach ($langcode as $lang){
$l_id = $lang['id'];
if (isset($filelayout['v_products_name_' . $l_id ])){ // do for each language in our upload file if exist
// we set dynamically the language vars
$v_products_name[$l_id] = smart_tags($items[$filelayout['v_products_name_' . $l_id]],$smart_tags,$cr_replace,false);
$v_products_description[$l_id] = smart_tags($items[$filelayout['v_products_description_' . $l_id ]],$smart_tags,$cr_replace,$strip_smart_tags);
** Changed to:**
foreach ($langcode as $lang){
$l_id = $lang['id'];
if (isset($filelayout['v_products_name_' . $l_id ])){ // do for each language in our upload file if exist
// we set dynamically the language vars
$v_products_name[$l_id] = smart_tags($items[$filelayout['v_products_name_' . $l_id]],$smart_tags,$cr_replace,false);
$v_new_field[$l_id] = smart_tags($items[$filelayout['v_new_field_' . $l_id]],$smart_tags,$cr_replace,false);
$v_products_description[$l_id] = smart_tags($items[$filelayout['v_products_description_' . $l_id ]],$smart_tags,$cr_replace,$strip_smart_tags);
Line 2005
** Original:**
$sql =
"INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."
(products_id,
language_id,
products_name,
products_description,";
** Changed to:**
$sql =
"INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."
(products_id,
language_id,
products_name,
new_field,
products_description,";
Line 2007
**
Original:**
VALUES (
'" . $v_products_id . "',
" . $key . ",
'" . zen_db_input($name) . "',
'" . zen_db_input($v_products_description[$key]) . "',
";
Changed to:
VALUES (
'" . $v_products_id . "',
" . $key . ",
'" . zen_db_input($name) . "',
'" . zen_db_input($v_new_field$key]) . "',
'" . zen_db_input($v_products_description[$key]) . "',
";
On this last change, be careful of your punctuation - it's easy to miss a quote or a '.'
I hope this helps anyone else who is trying to do the same thing that I was.