My first ZenCart tip

general.php

Do a search for “zen_get_products_description”. You will be taken to an area that says:

function zen_get_products_description($product_id, $language_id) {
global $db;
$product = $db->Execute("select products_description
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language_id . "'");
return $product->fields['products_description'];
}

Copy this entire section, and paste the section directly beneath it. Edit the new section so it looks like so:

I will also place comments in my files that I change with my name in them, right next to - or as close as I can get - to the line of code I’ve changed (as you can see in this example). This way, when I do the “Developer’s Tool Kit”, and I need to find something I’ve done, all I have to do is search for my name, and all of my edited files - along with the lines I’ve edited - will show up in my admin panel. Very nice.

// YOUR NAME HERE
function zen_get_products_description2($product_id, $language_id) {
global $db;
$product = $db->Execute("select products_description2
from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '" . (int)$product_id . "'
and language_id = '" . (int)$language_id . "'");
return $product->fields['products_description2'];
}

Save the file, appended with “NEW” (so, “generalNEW.php”). Then you want to save the file *again* as the original filename (”general.php”).

Why do I have you do this? Because if you make this change, and it works for you, that’s great. But if you ever upgrade your ZenCart installation, then the upgrade will overwrite these file changes, and you’ll lose everything. By keeping the files as “NEW”, they will remain untouched - so if you upgrade, right there is the stuff you need. Plus, you can keep track of where things are.


Page 1 2 3 4 5 6 7 8 9 10

Comments

Melvin says...
1

I can’t begin to tell you how wonderful this is. I’ve searched the Zen site over and over and nothing could touch what I needed. THANKS…. BUT…. The admin collect_info works, the preview_info works, but it’s not writing the input to the database. I opend php MyAdmin and verified the fields are correct. Also I verified the new records are writing to the database but the new fileds are blank. Additionally Both New records and Updated records are not writing to the new fields, AND I’m not getting any error messages. If I could beg your help, Can you point me to areas to look for possible mistakes or errors? I’m so close I can smell it…

Thanks a MILLION…

AdamN says...
2

You are a god(dess)! this has saved me so much hassle writing html code for mulitple descriptions in product listings/pages, the only change is Ive removed the original products description from the product page, so now my listings show a short info piece - the original product description section, and my product page just shows the secondary description - so much easier than writing class code into each description.

Many many thanks for the contrib.
Adam.

Trackbacks & Pingbacks

Leave a Reply