Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Products without categories


mfleeson

Recommended Posts

Just a silly bit of SQL. I realised that products I had used in previous promotion were not displaying as they were not in any categories, so here's a little bit of SQL to help fix databases if you've been using other tools to administrate your products.

1 - Check for products not in categories.

SELECT * FROM products WHERE products_id NOT IN (SELECT DISTINCT products_id FROM products_to_categories);

2 - If none display then you're fine. If they do then choose a category to put them in and get the category number.  If need be create a new category and look for the number in the database, i.e.

SELECT MAX(categories_id) FROM categories_description;

3 - Move the uncategorised products into your new category... If the previous query resulted in 211 then

INSERT INTO products_to_categories SELECT products_id,211 FROM products WHERE products_id NOT IN (SELECT DISTINCT products_id FROM products_to_categories);

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...