Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Extra Fields Display in Admin?


Guest

Recommended Posts

I've successfully added 2 extra fields to my product descriptions and have them displayed as part of a calculator function (thanks to some help here)- my problem is that I never got around to actually adding them to the admin area so I always have to use phpMyAdmin to apply them. I've tried a couple of the extra fields contribs but haven't had any luck getting them to work with these 2 existing extra fields (possibly the unique display on product_info causing problems?).

 

You can see an example of how they're used here:

http://oddsandinsonline.com/catalog/produc...roducts_id=3454

 

They are the two stitch count numbers (191 and 272 in this example) but you never actually see them because they are pulled directly into the custom calculator to display. I would just like to be able to add them at the backend as I can any of the other fields (such as manufacturer, name, quantity, weight etc) and I'm sure I'm just overthinking this and there must be a simple solution but I am absolutely missing it.

Link to comment
Share on other sites

So basically if I install one of the contribs and create new fields using the same names I could just 'copy' and then adjust my calculator script to call them from their new location? They're currently in their own fields in the products_description table.

Link to comment
Share on other sites

basically yes. But I was talking if you had already thousands of products where you have populated those fields you not want to go copy/paste one by one. Instead an sql script could populate the extra fields from the product description table. Once you're done you simply delete the additional columns from the products_description.

Link to comment
Share on other sites

Which I do- but if I export those records (I should have said export instead of 'copy' in the first place) then change the table listing to whatever the new one is I should be able to import them intact into the new field if I'm understanding you right- thanks so much, you've been a real help!

Link to comment
Share on other sites

not the phpmyadmin export facility. Either set few sql queries directly to the phpmyadmin to copy from one table to the other these fields

 

If you have problems do it at the php level with a php file so you could try a couple of records as a test. You only care about 2 fields so first you read all products into an array and then use the insert to insert them into the extra fields table.

Link to comment
Share on other sites

I've got the data copied over- I exported just the product id and stitches1 field and ran find and replace to change the table call and add the 1 or 2 as needed- but now I'm running into problems with the calculator-

This is the original code:

<?php

$product_stitches_query = tep_db_query("select p.products_id, pd.products_stitches1, pd.products_stitches2 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_stitches = tep_db_fetch_array($product_stitches_query);

 

$stitches1=$product_stitches['products_stitches1'];

$stitches2=$product_stitches['products_stitches2'];

 

 

And this is what I tried to replace it with:

<?php

$product_stitches1_query = tep_db_query("select p.products_id, pd.products_extra_fields_value from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_EXTRA_FIELDS . " pd where p.products_extra_fields_id = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_stitches1 = tep_db_fetch_array($product_stitches1_query);

 

$product_stitches2_query = tep_db_query("select p.products_id, pd.products_extra_fields_value from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_EXTRA_FIELDS . " pd where p.products_extra_fields_id = '2' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_stitches2 = tep_db_fetch_array($product_stitches2_query);

 

$stitches1=$product_stitches1['products_stitches1'];

$stitches2=$product_stitches2['products_stitches2'];

 

 

 

And then I get the following error message:

1054 - Unknown column 'pd.products_extra_fields_value' in 'field list'
Link to comment
Share on other sites

there is no products_extra_fields_value in TABLE_PRODUCTS_EXTRA_FIELDS

 

It is in the TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS

 

You need to use both tables in the query as you need both the fields name and value.

Link to comment
Share on other sites

I think I've got it now- I don't need the field name but only the value, id and pid so I think this should work (got my fingers crossed anyway!):

 

<?php

$product_stitches1_query = tep_db_query("select p.products_id, pd.products_extra_fields_value from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " pd where pd.products_extra_fields_id = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id");

$product_stitches1 = tep_db_fetch_array($product_stitches1_query);

 

$product_stitches2_query = tep_db_query("select p.products_id, pd.products_extra_fields_value from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " pd where pd.products_extra_fields_id = '2' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id");

$product_stitches2 = tep_db_fetch_array($product_stitches2_query);

 

$stitches1=$product_stitches1['products_extra_fields_value'];

$stitches2=$product_stitches2['products_extra_fields_value'];

 

It looks like it will work but just to be safe I'm going to leave my original, manual extra fields in the products_description table for awhile- thank you for the help and for being patient with me!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...