News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

SQL Code to add list of products to a category

Started by Herman01, March 24, 2014, 05:02:16 AM

Previous topic - Next topic

Herman01

Hi,

I am just starting out populating my virtue mart with data.

Right now I have a bunch of products listed in:

jos25_virtuemart_products
jos25_virtuemart_products_en_gb
jos25_virtuemart_product_prices

..and I have pretty much all the categories I need entered into:

jos25_virtuemart_categories
jos25_virtuemart_categories_en_gb
jos25_virtuemart_category_categories

What I'd like to do is make up a list of the products that I want to put into a category and then pop them in there using SQL - so much faster than using the user interface.

Is there some SQL code someone could help me out with where I could say:

Select (field list)
from table left join other_table
...etc...
where Virtuemart_product_id in (1,2,10,12,18,37,38,39,45,46,101)
into destination_table




jenkinhill

Suggest you use CSVI rather than develop sql yourself. Makes it much easier for product maintenance in the future. http://www.csvimproved.com/
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Herman01

Hi Kelvyn,

Thanks for the reply.

How can I find out what fields from what product tables need to be used in order to populate the appropriate fields in the product category tables?

Right now it looks like all I need to do is populate

jos25_virtuemart_product_categories.virtuemart_product_id with jos25_virtuemart_products.virtuemart_product_id

jos25_virtuemart_product_categories.virtuemart_category_id with jos25_virtuemart_categories.virtuemart_category_id

jos25_virtuemart_product_categories.virtuemart_ordering with 0 (for now anyway)

and what I'll do is

  • pick out the 10-15 products I want to work with
  • pick out the category i want them in
  • find out the product id numbers of those 10-15 products
  • find out the category_id number of that category i want them in
  • populate a csv with the list of product id numbers of those 10-15
  • populate the appropriate other column in the csv with the category_id number of that category i want them in
  • save it
  • import it

Does that sound right?