1

I've been attempting to add some custom fields to my osCommerce 2.3 installation. These fields (products_lot, products_location, products_serial_number, products_note)are all displaying as they should, and they all pull from a products_description table in my database. I'm migrating a database that already has these rows, and each field is displaying (pulling) field values exactly as I would expect.

However, when I try to save new values or update an existing product to these rows, it throws a 1054 error: 1054 - Unknown column 'products_lot' in 'field list'

If I move the tep_db_prepare_input() portion for these fields into a different array with product_description, the error isn't thrown, but none of the values actually save to the database. It either chops up those fields, or saves nothing at all where previously there was data. For instance, adding '5' to Products Location: yeilds a big fat nil in the database.

TL;DR It pulls the info just fine, but it fails to save it all, and I'm not sure why . . .

Here's the categories.php file I'm working with to create and store these fields:

http://pastebin.com/raw.php?i=wHrddQyq

All MySQL rows are named to match, so products_description table has products_lot, etc.

LukePatrick
  • 37
  • 1
  • 14
  • Okay, so I *think* I fixed it: `[$language_id]` on line 264 was causing it to act weirdly. It would chop entries and save incorrectly. Can anyone explain to me why this would be? I'd hazard that it has something to do with my rows encoding. – LukePatrick Mar 30 '15 at 19:43

1 Answers1

3

If your custom fields are in the products table, rows in that table are not stored for each language ID. The products_description table has rows for each language ID.

Your code for the custom fields is in the $sql_data_array that's being inserted/updated in the products table. If your custom fields are different for each language and they're stored in the products_description table, you need to move those fields into the $sql_data_array inside the

    for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 

loop. Otherwise, $language_id will be undefined.

user2170627
  • 140
  • 5
  • Perfect! Thanks for the explanation, that makes a lot more sense now. I should have seen that, honestly. I'm porting over a lot of old code and just didn't catch it. – LukePatrick Mar 31 '15 at 02:17