Jump to content

Category ID keeps increasing by 1!


Recommended Posts

Hi there. I managed to delete the test category (realised l had to delete the product it contained too).

In the process l had already created my own first category.

Test category deleted.

Own first category re-added.

HOWEVER: its category ID was appearing as 3, despite no other categories in existence.

I deleted it. Cleared cache.

Created my own first category again. HOWEVER: it appeared with an ID of 4 this time. So it keeps increasing incrementally, with CubeCart for some reason never forgetting the deletion of previous categories inasmuch as their category number lives on, forever, and ever, and ever, and ever and ever.

 

 

Is there a way to directly edit category ID? I have a set menu of categories. They MUST all have the same category number, across all carts that l am setting up.

Link to comment
Share on other sites

The category is uses an auto increment so will always increase by one - that is Joe’s it works - standard database functionality.  You could delete all categories and set the auto increment back to 0 and start again BUT creating a menu system that is dependent on fixed cat I’d numbers is a recipe for disaster 

Link to comment
Share on other sites

Hi there, when l delete all cats, the highest previous cat no. is not forgotten, and increment starts from there (that's the crux of my OP in fact).

 

I know of no way to set auto increment back to 0. Please divulge.

Link to comment
Share on other sites

CubeCart creates these tables to have the ID column auto-increment so that each new insertion acquires the next highest value that the table has ever had. That is, if the table once had the highest 'cat_id' value of 5, the next insertion would automatically have a 'cat_id' of 6.

Yes, you can manually change the 'cat_id' values (using phpMyAdmin, for example) but each row must continue to have a unique 'cat_id' value. If, for example, 'TestCat2', when inserted into the table, acquired a 'cat_id' of 7, you can manually change that to 2 as long as there is no other row that currently has a 'cat_id' of 2.

To completely start over with a fresh CubeCart_category table, issue the TRUNCATE TABLE CubeCart_category statement. (You can do this in phpMyAdmin, or using CubeCart's admin, Maintenance, Database Query tab.) Having a fresh table means the table will start the auto-increment at 1.

Just to remind everyone, the 'cat_id' is the value that all other tables that deal with categories use to make their reference to: category images, sub-categories, assigned products, etc.

 

  • Like 1
Link to comment
Share on other sites

9 minutes ago, bsmither said:

you can manually change that to 2 as long as there is no other row that currently has a 'cat_id' of 2.

Yes you can but as you know, you then start to get into the issue of other tables that use this reference as a key.

 

10 minutes ago, bsmither said:

issue the TRUNCATE TABLE CubeCart_category statement. (You can do this in phpMyAdmin, or using CubeCart's admin, Maintenance, Database Query tab.) Having a fresh table means the table will start the auto-increment at 1.

Yes that is true but also assumes that any other table using this reference is also truncated or changed

2 hours ago, cubicsquare said:

Sorry but your replies don't make sense to me. Thanks anyway.

I wasnt intending to be obscure - but if you dont know what is meant by setting the table index increment back to zero, trying to explain or you trying to do can just cause far more trouble. If you dont mind learning and experimenting and can throw the whole database away if you get it wrong then by all means give it a go

Link to comment
Share on other sites

Ok i've decided to leave category IDs alone and let them do their thing.

Seems odd that they are even displayed if they are not really user-oriented as such. Seems that they are more to do with internal machine talk.

Link to comment
Share on other sites

Posted (edited)

@havenswift-hosting  who said it did?

 

EDIT: OK l realise l said it did. Well, i've decided it's no longer that important to me. I just wanted dual functionality, cat id and cat name, so that l could refer to categories by either, in case l ran into a shopping cart that insisted on cat ID rather than prosaic cat name.

 

 

Edited by cubicsquare
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...