Editing Easy Populate to recognize extra description fields
Now, in my last post, I had said that if I could figure out how to edit Easy Populate to accept and distribute my extra description fields, I would be golden.
Well, call me “the Golden Child”. I did it.
Now I will share with you how I did it so you may gleam with me.
Surprisingly, aside from some brief idiocy on my part, it wasn’t too hard to accomplish this task. It only required the editing of two files:
- zencart/admin/includes/easypopulate/easypopulate_import.php
- zencart/admin/includes/easypopulate/easypopulate_export.php
That would, indeed, make sense since these two files are what handles the importing and exporting of data. So, let’s see what I changed.
easypopulate_import.php
Lines 333-339:
foreach ($ep_languages as $lang)
{
$sql2 = 'SELECT * FROM (' . TABLE_PRODUCTS_DESCRIPTION . ') WHERE products_id = ' . (int)$row['v_products_id'] . ‘ AND language_id = ‘ . (int)$lang['id'];
$result2 =& ep_query($sql2);
$row2 = $result2->getRow(0, ECLIPSE_DB_ASSOC);
$row['v_products_name_' . $lang['code']] = $row2['products_name'];
$row['v_products_description_' . $lang['code']] = $row2['products_description'];
You want to append that with:
$row['v_products_description2_' . $lang['code']] = $row2['products_description2'];
Line 774 and 775 needs to be changed to this:
$epLayout['products_description'] = array(’products_name’, ‘products_description’, ‘products_description2′, ‘products_url’);
$epControl['smart_tags'] = array(’products_name’ => false, ‘products_description’ => true, ‘products_description2′ => true, ‘products_url’ => false, ‘products_short_desc’ => true);
Save, and move to…
easypopulate_export.php
Lines 26-30 look like so:
foreach ($ep_languages as $lang)
{
$filelayout = array_merge($filelayout , array(
'v_products_name_' . $lang['code'] => $iii++,
‘v_products_description_’ . $lang['code'] => $iii++,
Copy the last line and paste it at the end, so it changes to:
foreach ($ep_languages as $lang)
{
$filelayout = array_merge($filelayout , array(
'v_products_name_' . $lang['code'] => $iii++,
‘v_products_description_’ . $lang['code'] => $iii++,
‘v_products_description2_’ . $lang['code'] => $iii++,
Do the same with lines 100-103 - just copy line 103 and paste it at the end so it looks like this:
foreach ($ep_languages as $lang)
{
$filelayout['v_products_name_' . $lang['code']] = $iii++;
$filelayout['v_products_description_' . $lang['code']] = $iii++;
$filelayout['v_products_description2_' . $lang['code']] = $iii++;
Line 264 starts with $filelayout_sql = 'SELECT, and towards the bottom of that section, you’ll see (at line 281 ): pd.products_description as description,. Just copy that line, and again, paste it into the next line.
Lines 650-653:
if ($row2 = $result2->getRow(0, ECLIPSE_DB_ASSOC))
{
$row['v_products_name_' . $lang['code']] = $row2['products_name'];
$row['v_products_description_' . $lang['code']] = $row2['products_description'];
Do another copy/paste so it looks like this:
if ($row2 = $result2->getRow(0, ECLIPSE_DB_ASSOC))
{
$row['v_products_name_' . $lang['code']] = $row2['products_name'];
$row['v_products_description_' . $lang['code']] = $row2['products_description'];
$row['v_products_description2_' . $lang['code']] = $row2['products_description2'];
Line 667 should be changed to look like so:
ep_query('INSERT INTO ' . TABLE_PRODUCTS_DESCRIPTION . ' (products_id, language_id, products_name, products_description, products_description2) VALUES (' . (int)$row['v_products_id'] . ‘, ‘ . (int)$lang['id'] . ‘, ‘ . ep_db_input($default_desc_row['products_name']) . ‘, ‘ . “”” . ‘)’);
667-671 should have another line added to it so it looks thusly:
ep_query('INSERT INTO ' . TABLE_PRODUCTS_DESCRIPTION . ' (products_id, language_id, products_name, products_description, products_description2) VALUES (' . (int)$row['v_products_id'] . ‘, ‘ . (int)$lang['id'] . ‘, ‘ . ep_db_input($default_desc_row['products_name']) . ‘, ‘ . “”” . ‘)’);
$error_detect = EASYPOPULATE_MSGSTACK_PRODUCTS_EXPORT_FIX;
$products_error_count++;
$row['v_products_name_' . $lang['code']] = $default_desc_row['products_name'];
$row['v_products_description_' . $lang['code']] = ”;
$row['v_products_description2_' . $lang['code']] = ”;
Upload and save.
You may now import and export using Easy Populate, and get your new fields to come and go as needed. I would imagine you could use the same method for other fields, should you so choose to add them to your site. You could use this idea as a basis for that (or, wait until I need to do something else someday and post the how-to again, but I wouldn’t hold my breath!)



Hi,
I need a solution for my problem. On my category pages, I need my products to list three bullet points (all under the product thumbnail image), all must be seperate fields. Will this workaround that you developed solved this? I will also need it to be be easy populatable (if that is a word).
Thanks for sharing.
Spoken on March 11th, 2008 at 5:50 pm