Jump to content

Category ID keeps increasing by 1!


cubicsquare

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

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.

 

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

@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.

 

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...