Forum Moderators: open

Message Too Old, No Replies

foreach issue

trying to customize a script, getting an error

         

doodlebee

2:45 pm on Apr 29, 2007 (gmt 0)

10+ Year Member



Hi all. I'm hoping someone can help me out with this. I'm doing a ZenCart, and have managed to hack it to hell and back to add in two extra fields for the products description. I'm also using a contribution called "Easy Populate", and I've managed to get the exporting of data with the two extra fields to go slicker than snot on a doorknob. (I'm all proud of myself!)

But of course when I go to actually *import* data, my hackjob isn't working so well. So I was hoping someone here could help me with the semantics, as I seem to be turning my brain into mush trying to get it right.

So, the table in the database has two new fields that I created: "products_description2" and "products_description3". Like I said, I've managed to get absolutely everything to work great - I just can't get the Easy Populate hack to *import* the edited data for these two fields.

The current code (the original working code) for the products_description area looks like so:

   $epLayout['products_description'] = array('products_name', 'products_description', 'products_url');
$epControl['smart_tags'] = array('products_name' => false, 'products_description' => true, 'products_url' => false, 'products_short_desc' => true);
if (isset($ep_supported_mods['psd']))
{
$epLayout['products_description'][] = 'products_short_desc';
}
$sql_array = array();
foreach ($ep_languages as $lang)
{
if ($product_is_new)
{
$sql_array[$lang['id']]['language_id'] = $lang['id'];
$sql_array[$lang['id']]['products_id'] = $v_products_id;
$sql_array[$lang['id']]['products_name'] = 'new product';
}
foreach ($epLayout['products_description'] as $field_name)
{
if (isset($filelayout['v_' . $field_name . '_' . $lang['code']]))
{
$sql_array[$lang['id']][$field_name] = ep_smart_tags($items[$filelayout['v_' . $field_name . '_' . $lang['code']]], $epControl['smart_tags'][$field_name]);
}
}
}

What *I* need to do is somehow add "products_description2" and "products_description3" into this section of code. All attempts by me have resulted in utter failure. Either nothing happens at all (the two new fields are not recognized), or I get a nice happy "foreach" error.

If anyone can help me figure out how to add these two fields into this section of code would be greatly appreciated.

Thanks so much :)

coopster

4:40 pm on Apr 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Looks to me like that is going to require a knowledge of "Easy Populate" which apparently not too many people around here are using. You'll have to pull their documentation and struggle through it by the looks of it doodlebee. Or just write your own code to handle the update and scrap the extension package you are trying to understand.

doodlebee

1:43 am on May 12, 2007 (gmt 0)

10+ Year Member



Sorry it took so long to come back to this thread... but I got it :) Turns out I had the wrong section. What I did was the following (in case anyone ever needs to do this):

Copied any instance of "products_description" in the easy_populate/easy_populate_import.php file and pasted it twice, changing the next 2 lines to "products_description2" and products_description3" (at lines 339, 774, 775), and the import worked perfectly. Seems like I was overthinking it!