Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing admin so you can put in your own products_id number


Guest

Recommended Posts

Posted

Hi-

 

Could anyone tell me what files and code I would need to change in admin to have a field where I can enter my own unique products_id number and not have an auto-incremented number? This would be a BIG help.

 

I have done a search, but haven't turned up anything helpful :(

 

Thanks for your time,

 

Paul :)

Posted

Yes im sure this can be done but requires recoding of the admin/categories.php file and a change of some tables. Take a look at the file it will give you a good start.

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Posted

Thanks for the reply!! I looked into the categories file and found several calls to

 

function tep_db_insert_id() {

return mysql_insert_id();

}

 

in the functions/database file. This returns the last auto_increment number from the last update to the database. As this number is stored on the server, it is accessible from any php file and that would take a lot of changing unless all updates to database when creating a product happen in the categories.php file? If this were the case, you could just include an input field for the products_id and use that value throughtout when creating a product??

 

Any ideas?

Posted

I am sorry that I am of no help to you, but I want to say that your idea is BRILLIANT. I sell records, and it would be a great idea to use the record numbers as product ID's.

 

Let's hope there is a way :wink:

Posted

Pretty simple guys.

 

1.) Change the settings for your db. Easiest way: go into something like PHPmyADMIN and change the products_id field so that it doesn't auto-increment.

 

2.) Go into your configuration.php file and change the "insert" script so that it now inserts the value of your text box (which you will now have to create) instead of the '' (single quotes) found there now.

 

I think that is about it. There is probably more, but it isn't coming to mind right now. If I think of it, I will post again.

 

HTH,

-Chris

Chris Sullivan

Posted

I am still relatively new to osc, but I thought I should add something to this discussion.

 

First, "products_id" is a field that is used by several other tables in the database to reference your products. What you want is "products_model" AND/OR add a field called something like "products_yourid".

 

I was going to add a field called "products_sku" in my osc customization until I realized that "products_model" was intended for that. Or maybe I came to this conclusion backwards - I was looking into using easypopulate which is not easy at all, but requires that each "products_model" entry be unique while I thought it was for refining a product's catagory such as "product": day; day, sunny model; day, cloudy model; day, partly sunny model; day, rainy model.

 

To conclude, I would recommend: do not mess with "products_id", but use either "products_model" or add a field of your chosen name which will be easier than changing everything related to "products_id".

 

This may not be what each of you is asking, but hope it helps some. And, if anyone has related info or correction to this, I'd welcome it.

Posted

Well, after a LOT of messing around, I have managed to get it to work. How stable it will be is another question as my site is not opertional yet (far from it !).

 

I will post alterations if and when I find out it's stable. Basically, you need to change all instances of products_id in the database to be varchar(12) instead of int(11). Then you need to add a field in admin to enter a product id number (admin/categories.php). Also, in this file, you need to make a bunch of changes to use the inputed products_id and update the database with this when creating a database entry. As I said, it was a lot of bother, but it seems to work.

 

If you try and add a product to the database with a products_id that has already been used, it will throw an error, but will not do any damage- this is because products_id is a primary key.

 

Thanks for all your help.

 

Paul.

Posted

Darn it, can't edit my posts!!! Wanted to also add that three tables get updated when admin adds an entry: products, products_description and products_to_categories.

 

P.

Archived

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

×
×
  • Create New...