Jump to content



Photo
- - - - -

Add More Fields


  • Please log in to reply
165 replies to this topic

#21   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 27 September 2011 - 11:54

Can not fint the following lines in my ADMIN/CATEGORIES.PHP

FIND (around line 470):

} elseif (tep_not_null($HTTP_POST_VARS)) {
$pInfo->objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];

If you are trying to install it in a 2.3 shop, this addon has not been converted to work with 2.3.

#22   booksfromhome

booksfromhome
  • Members
  • 32 posts
  • Real Name:David
  • Gender:Male

Posted 27 September 2011 - 23:18

that makes sence

#23   booksfromhome

booksfromhome
  • Members
  • 32 posts
  • Real Name:David
  • Gender:Male

Posted 29 September 2011 - 02:18

I like a lot of others are anxious to get a copy of this code for v2.3.1

I just had to rebuild my site and loaded googlefeeder in, it works very well. I am holding off repopulating the site with my 300+ older books until I can add extra fields to the products

if you can work this code into your schedule we all would appreciate it

#24   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 29 September 2011 - 03:17

I don't think it will be too long. I have the files converted, though not tested, and still have to write the install instructions.

#25   erik1432

erik1432
  • Members
  • 4 posts
  • Real Name:Erik

Posted 09 October 2011 - 20:46

Thanks Jack for all the cool addons you make for oscommerce!
I use Header Tags SEO and Google XML SEO and they are both working perfectly.
I do not know much about PHP but with your very clear install instructions it always worked out.

The 'add more fields' addon that your working on sounds great.
I already tried to install another extra field contribution but that seems to be not working with your Header Tags SEO contribution.
Some pieces of the code that i need to replace are already replaced with your contribution.

Do you have a estimate timeline when the install instructions will be ready ?

Thanks again and please keep up the good work!
I think there will be much Oscommerce shops that are using your contributions.

#26   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 09 October 2011 - 23:35

Can not fint the following lines in my ADMIN/CATEGORIES.PHP

FIND (around line 470):

} elseif (tep_not_null($HTTP_POST_VARS)) {
$pInfo->objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];

Then you have an edited categories file or maybe are trying to install it in an unsupported version.

#27   booksfromhome

booksfromhome
  • Members
  • 32 posts
  • Real Name:David
  • Gender:Male

Posted 11 October 2011 - 15:55

I have not directly modified the admin/categories file. the only add on was your googlebase feed.

I downloaded my version of oscommerce 2.3.1 from vodahost. I searched the entire categories file for the keyword "pinfo" and there was no match.


line 470:


function updateGross() {
var taxRate = getTaxRate();
var grossValue = document.forms["new_product"].products_price.value;

if (taxRate > 0) {
grossValue = grossValue * ((taxRate / 100) + 1);
}

document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
}

#28   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 11 October 2011 - 16:46

I have not directly modified the admin/categories file. the only add on was your googlebase feed.

I downloaded my version of oscommerce 2.3.1 from vodahost. I searched the entire categories file for the keyword "pinfo" and there was no match.


line 470:


function updateGross() {
var taxRate = getTaxRate();
var grossValue = document.forms["new_product"].products_price.value;

if (taxRate > 0) {
grossValue = grossValue * ((taxRate / 100) + 1);
}

document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
}

If I look in a stock copy of that file here, I see the above code at that line but I also see pInfo at line 404. If you don't see that then there must be something wrong with your file. In that case, you may want to download the oscommerce package from here.

#29   booksfromhome

booksfromhome
  • Members
  • 32 posts
  • Real Name:David
  • Gender:Male

Posted 11 October 2011 - 17:25

your right, I must have searched case senitive.

This is my line 404, It does not look the same as what was expected


line 404:


$pInfo = new objectInfo($parameters);

if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product = tep_db_fetch_array($product_query);

$pInfo->objectInfo($product);

$product_images_query = tep_db_query("select id, image, htmlcontent, sort_order from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product['products_id'] . "' order by sort_order");
while ($product_images = tep_db_fetch_array($product_images_query)) {
$pInfo->products_larger_images[] = array('id' => $product_images['id'],
'image' => $product_images['image'],
'htmlcontent' => $product_images['htmlcontent'],
'sort_order' => $product_images['sort_order']);
}

#30   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 11 October 2011 - 17:38

your right, I must have searched case senitive.

This is my line 404, It does not look the same as what was expected


line 404:


$pInfo = new objectInfo($parameters);

if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product = tep_db_fetch_array($product_query);

$pInfo->objectInfo($product);

$product_images_query = tep_db_query("select id, image, htmlcontent, sort_order from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product['products_id'] . "' order by sort_order");
while ($product_images = tep_db_fetch_array($product_images_query)) {
$pInfo->products_larger_images[] = array('id' => $product_images['id'],
'image' => $product_images['image'],
'htmlcontent' => $product_images['htmlcontent'],
'sort_order' => $product_images['sort_order']);
}

That's because, as mentioned a few posts up, it has not been converted to work with 2.3. I hope to have that version uploaded witing a week though.

#31   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 24 October 2011 - 12:28

A new version, http://addons.oscommerce.com/info/8073, has been uploaded. This addon is now 2.3 compatible.

#32   erik1432

erik1432
  • Members
  • 4 posts
  • Real Name:Erik

Posted 24 October 2011 - 18:54

Dear Jack,

Is this contribution working with your other contribution 'Header Tags SEO' ?
Some pieces of the code that needs to be replaced are already been replaced with Header Tags SEO code.

For example:

FIND (around line 283):

'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));

ADD BENEATH:
/**** Begin Add More Fields ****/
$addedFieldsArray = GetAddedProductFields($_GET['pID'], $_GET['cPath']);
if (count($addedFieldsArray) > 0) {
foreach ($addedFieldsArray as $fields) {
if ($fields['table_name'] == TABLE_PRODUCTS_DESCRIPTION) {
$addedFields = array($fields['field_name'] => tep_db_prepare_input($_POST[$fields['field_name']][$language_id]));
$sql_data_array = array_merge($sql_data_array, $addedFields);
}
}
}
/**** End Add More Fields ****/

My piece of the code looks like this:

$languages = tep_get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
$language_id = $languages[$i]['id'];
/*** Begin Header Tags SEO ***/
$sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]),
'products_head_title_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_title_tag'][$language_id])) ? tep_db_prepare_input(strip_tags($HTTP_POST_VARS['products_head_title_tag'][$language_id])) : tep_db_prepare_input(strip_tags($HTTP_POST_VARS['products_name'][$language_id]))),
'products_head_desc_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_desc_tag'][$language_id])) ? tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]) : tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id])),
'products_head_keywords_tag' => ((tep_not_null($HTTP_POST_VARS['products_head_keywords_tag'][$language_id])) ? tep_db_prepare_input(strip_tags($HTTP_POST_VARS['products_head_keywords_tag'][$language_id])) : tep_db_prepare_input(strip_tags($HTTP_POST_VARS['products_name'][$language_id]))));
/*** End Header Tags SEO ***/
if ($action == 'insert_product') {
$insert_sql_data = array('products_id' => $products_id,
'language_id' => $language_id);

As you can see this piece of code is already replaced by your other contribution.

The next step in your install file is the same story:

FIND (around line 332):
} elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$product = tep_db_fetch_array($product_query);
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
$dup_products_id = tep_db_insert_id();
$description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}

If i replace this piece of code the code that has been already replaced by Header Tags SEO will be lost.


Can you please check and let me know how to proceed ?

Thanks!

#33   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 24 October 2011 - 22:01

Dear Jack,

Is this contribution working with your other contribution 'Header Tags SEO' ?
Some pieces of the code that needs to be replaced are already been replaced with Header Tags SEO code.

If i replace this piece of code the code that has been already replaced by Header Tags SEO will be lost.


Can you please check and let me know how to proceed ?

Thanks!

When two contributions share the same code you have to eidt the code and merge the changes. This is true for any contribution. Instructions can't be given for how to do that since there are too many possibilities. Most people use a compare program, like WinMerege, to compare and merge the two pieces of code.

#34   fender71

fender71
  • Members
  • 1 posts
  • Real Name:Abner

Posted 25 October 2011 - 05:34

Hi Jack,

First of all i just want to say thanks very much for your great (add ons)contributions that you have created or refurbished for sharing them to everyone and also for the support that you give for them. cheers!

i have a question regarding the install instruction for V2.3 and up.
one is this instruction below:

________________________________________________________________________
FIND (around line 470):

} elseif (tep_not_null($HTTP_POST_VARS)) {
$pInfo->objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];

ADD BENEATH:

/**** Begin Add More Fields ****/
$addedFieldsArray = GetAddedProductFields($_GET['pID'], $_GET['cPath']);
$addMoreFieldsArray = array();
if (count($addedFieldsArray) > 0) {
foreach ($addedFieldsArray as $field) {
$addMoreFieldsArray[$field['field_name']] = $_POST[$field['field_name']];
}
}
/**** End Add More Fields ****/


________________________________________________________________________

I cannot find this code below for me to add the above code underneath it anywhere in the admin/categories.php even on a fresh untouched oscommerce V2.3 files.

} elseif (tep_not_null($HTTP_POST_VARS)) {
$pInfo->objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];

Same as the instructions below:

________________________________________________________________________
FIND (around line 756):

} elseif ($action == 'new_product_preview') {
if (tep_not_null($HTTP_POST_VARS)) {
$pInfo = new objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];
} else {
$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");


REPLACE WITH:


Thanks Jack.

#35   HaseebWarraich

HaseebWarraich
  • Members
  • 3 posts

Posted 25 October 2011 - 05:43

hey plez ans this question

http://forums.oscomm...duct-name-base/

#36   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 25 October 2011 - 12:27

Hi Jack,

First of all i just want to say thanks very much for your great (add ons)contributions that you have created or refurbished for sharing them to everyone and also for the support that you give for them. cheers!

i have a question regarding the install instruction for V2.3 and up.
one is this instruction below:

Thank you for the kind workds.

That code in that instruction is only in the install file (not in the included file). It is just a mistake and you can skip it.

#37   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 25 October 2011 - 12:28

hey plez ans this question

http://forums.oscomm...duct-name-base/

This is the support thread for the Add More Fields contribution. Please only post questions related to it here.

#38   altoid

altoid
  • Community Sponsor
  • 1,001 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Hollidaysburg, Pennsylvania

Posted 26 October 2011 - 01:54

When two contributions share the same code you have to eidt the code and merge the changes. This is true for any contribution. Instructions can't be given for how to do that since there are too many possibilities. Most people use a compare program, like WinMerege, to compare and merge the two pieces of code.


Hi Jack, I think I am dealing with the same situation. i was using Winmerge to do the install and for the instructions for 7) In admin/categories.php I ran into the Header Tags issue.

For a 2.3.1 shop....

Here's my existing categories.php code:

			$dup_products_id = tep_db_insert_id();
		   /*** Begin Header Tags SEO ***/
			$description_query = tep_db_query("select language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
			while ($description = tep_db_fetch_array($description_query)) {
			  tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_head_title_tag']) . "', '" . tep_db_input($description['products_head_desc_tag']) . "', '" . tep_db_input($description['products_head_keywords_tag']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
			}
		   /*** End Header Tags SEO ***/

and here's the part that it appears 'add more fields' calls for

			$dup_products_id = tep_db_insert_id();
			$description_query = tep_db_query("select * from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
			while ($description = tep_db_fetch_array($description_query)) {
			  tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed " . $prodcutsDescStr . ") values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0'" . $prodcutsDescValues . ")");
			}
			/**** End Add More Fields ****/
 


I am guessing we need to leave the Header Tags code intact or it won't work?

Also, for the new code it looks like a typo for products vs prodcuts.

Thanks
I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.
I remember what it was like when I first started with osC. It can be overwhelming.
However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.
There are several good pros here on osCommerce. Look around, you'll figure out who they are.

#39   Jack_mcs

Jack_mcs
  • Members
  • 26,428 posts
  • Real Name:Jack York
  • Gender:Male
  • Location:Michigan

Posted 26 October 2011 - 03:09


Hi Jack, I think I am dealing with the same situation. i was using Winmerge to do the install and for the instructions for 7) In admin/categories.php I ran into the Header Tags issue.

For a 2.3.1 shop....

Here's my existing categories.php code:

			$dup_products_id = tep_db_insert_id();
		   /*** Begin Header Tags SEO ***/
			$description_query = tep_db_query("select language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
			while ($description = tep_db_fetch_array($description_query)) {
			  tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_head_title_tag']) . "', '" . tep_db_input($description['products_head_desc_tag']) . "', '" . tep_db_input($description['products_head_keywords_tag']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
			}
		   /*** End Header Tags SEO ***/

and here's the part that it appears 'add more fields' calls for

			$dup_products_id = tep_db_insert_id();
			$description_query = tep_db_query("select * from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
			while ($description = tep_db_fetch_array($description_query)) {
			  tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed " . $prodcutsDescStr . ") values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0'" . $prodcutsDescValues . ")");
			}
			/**** End Add More Fields ****/
 


I am guessing we need to leave the Header Tags code intact or it won't work?

Also, for the new code it looks like a typo for products vs prodcuts.

Thanks

The existing code lists every field to be loaded so if a field isn't listed, it won't be loaded. The Add More Fields code is telling it to load all fields since it doesn't know the names of all of them at that point. So just replace the line beginning with
$description_query
with the new one. For the line beginning with[code]tep_db_query("insert into[/code]you may have to merge the change with the exiting fields since yours may vary, which it will in your case due to Header Tags.

Thanks for mention the spelling mistake. it shouldn't cause any problems, except for a minor php warning, but I will change it in the next version. You can do a mass search and replace for now if you like.

#40   altoid

altoid
  • Community Sponsor
  • 1,001 posts
  • Real Name:Steve
  • Gender:Male
  • Location:Hollidaysburg, Pennsylvania

Posted 26 October 2011 - 10:07

The existing code lists every field to be loaded so if a field isn't listed, it won't be loaded. The Add More Fields code is telling it to load all fields since it doesn't know the names of all of them at that point. So just replace the line beginning with

$description_query
with the new one. For the line beginning with[code]tep_db_query("insert into[/code]you may have to merge the change with the exiting fields since yours may vary, which it will in your case due to Header Tags.

Thanks for mention the spelling mistake. it shouldn't cause any problems, except for a minor php warning, but I will change it in the next version. You can do a mass search and replace for now if you like.


will do Jack on that, thanks for the follow up.
I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.
I remember what it was like when I first started with osC. It can be overwhelming.
However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.
There are several good pros here on osCommerce. Look around, you'll figure out who they are.