VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Herman01 on March 24, 2014, 05:02:16 AM

Title: SQL Code to add list of products to a category
Post by: Herman01 on March 24, 2014, 05:02:16 AM
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



Title: Re: SQL Code to add list of products to a category
Post by: jenkinhill on March 24, 2014, 11:22:09 AM
Suggest you use CSVI rather than develop sql yourself. Makes it much easier for product maintenance in the future. http://www.csvimproved.com/
Title: Re: SQL Code to add list of products to a category
Post by: Herman01 on March 24, 2014, 13:26:23 PM
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

Does that sound right?