Latest News: (loading..)
Jack_mcs

Add More Fields

188 posts in this topic

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.

Share this post


Link to post
Share on other sites

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);

}

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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']);

}

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hi Jack,

 

I'm get the error below. It's when I go into "Categories/Products" then hit the ">" button!!

 

I'm using 2.3...

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from products p, products_description pd where p.products_id = pd.products_id an' at line 1

 

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 products p, products_description pd where p.products_id = pd.products_id and p.products_id = '75'

 

 

 

Any help would be appreciated.

 

Thank you!!

Edited by brosebro

Share this post


Link to post
Share on other sites

That's not code changed by this contribution so you either made a mistake when installing it or that error is from something else. There is a completed file in the archive that you can compare against.

Share this post


Link to post
Share on other sites

Hai Jack,

 

How can i Display the added fields & Values, separately in Shop Side like Product description

Share this post


Link to post
Share on other sites

Hai Jack,

 

How can i Display the added fields & Values, separately in Shop Side like Product description

See the installation instruciton file.

Share this post


Link to post
Share on other sites

hi jack,

 

i have installed this wonderful contribution (thanks a lot!!!) and i am very happy with it...i just wondered if there is an 'easy' way to add the new fields to the advanced search of the shop...?

 

best regards, tom

Share this post


Link to post
Share on other sites

hi jack,

 

i have installed this wonderful contribution (thanks a lot!!!) and i am very happy with it...i just wondered if there is an 'easy' way to add the new fields to the advanced search of the shop...?

 

best regards, tom

No, there's nothing in the code to do that currently. If you have the new field added into the products description and your search code is setup to look at the description, then the new field would be searched automatically. But if you want to be able to search specific fields you add, then that would have to be coded. I'll see about adding that to the next version.

Share this post


Link to post
Share on other sites

Dear Jack,

 

I got the contribution working now for couple of days.

Seems to work verry good! Thank you for that.

 

I found only one problem when deleting extra fields.

When i deleted two fields the easypopulate.php file seems to be not correct.

 

-----------------------------------------------------------------------------------------------------------------------

$custom_fields[TABLE_PRODUCTS] = array(,,'Verzendkosten' => 'Verzendkosten','Levertijd' => 'Levertijd','gtin' => 'gtin'); // this line is used if you have no custom fields to import/export

$custom_fields[TABLE_PRODUCTS_DESCRIPTION] = array(); // this line is used if you have no custom fields to import/export

-------------------------------------------------------------------------------------------------------------------------

 

When i deleted the two ,, before 'verzendkosten' everything is working again.

I don't know a lot about php but i thought maybe this will help out others.

 

Thanks again.

Share this post


Link to post
Share on other sites

Dear Jack,

 

I got the contribution working now for couple of days.

Seems to work verry good! Thank you for that.

 

I found only one problem when deleting extra fields.

When i deleted two fields the easypopulate.php file seems to be not correct.

 

-----------------------------------------------------------------------------------------------------------------------

$custom_fields[TABLE_PRODUCTS] = array(,,'Verzendkosten' => 'Verzendkosten','Levertijd' => 'Levertijd','gtin' => 'gtin'); // this line is used if you have no custom fields to import/export

$custom_fields[TABLE_PRODUCTS_DESCRIPTION] = array(); // this line is used if you have no custom fields to import/export

-------------------------------------------------------------------------------------------------------------------------

 

When i deleted the two ,, before 'verzendkosten' everything is working again.

I don't know a lot about php but i thought maybe this will help out others.

Thanks for reporting that. I had some problems getting the deletion to work but I thought I had it fixed since I couldn't reproduce it. I'll have another go at it.

Share this post


Link to post
Share on other sites

Jack,

 

I noticed that some were having difficuty installing this contrib with Header Tags code. I found it easier to use the admin/categories.php in this package and then 'weave in' the Header Tags edits. Although there were a couple more minor edits that had to bemade but it was alot less pain than the other way.

 

I hope this help someone.

Share this post


Link to post
Share on other sites

This Contrib works great! - but is there a way to make the data field bigger?

 

I would very much like it to be the same size as the product description data field.

 

But i cant figure out were the data input fields size is defined.

 

Thank you

 

- Jesper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now