Jump to content
Sign in to follow this  

Script properly fixes category counts when the database is populated manually or loaded with a CSV file

Recommended Posts

Hi all, there used to be a simple script required to fix the category counts when the database was populated manually or loaded with a CSV file. The categories have been created/added and now I have about 11000 products to add and all have their allocated category/sub category number. However, after adding a few products as a test the CubeCart_category_index stays empty and all products need to be manually allocated to their individual category. 

Is the following work around still the same as at https://swscripts.com/cubecart-mods/fixcatcount.html ?

I looked in the forum and to my amazement I could not find anything about this.


Thank you for your direction,


Share this post

Link to post
Share on other sites

I actually found the answer. Yes the mod remains the same :

TRUNCATE TABLE CubeCart_category_index;

INSERT INTO CubeCart_category_index (product_id, cat_id) SELECT product_id, cat_id FROM CubeCart_inventory;

On a different note, what does the primary field do in CubeCart_category_index ?

Thank you


Share this post

Link to post
Share on other sites

In CubeCart, one can associate a product to more than one category, with one of those categories designated as the Primary category. This designation is indicated by a true-ish value in the 'primary' column.

The Primary category (cat_id) is also recorded in each product's record in CubeCart_inventory.

The Primary category is what will construct the breadcrumb path when viewing that product, regardless of the path of pages one took to get there (Sale Items, Searches, or secondary category path). Also, if using Shipping by Category, only the Primary category contributes to the list of available shipping options.

When deciding to show what products are visible (a logged-in admin overrides this), if any of the associated categories is enabled and not hidden, then the product will be shown.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this