Additional Images not shown after migration but exist in database!!!

Started by csho, May 24, 2014, 09:25:50 AM

Previous topic - Next topic

csho

Hello,
I discovered that the problem with additional images was the following:
The additional images where stored in the database correctly BUT they where not connected with product ids in the virtuemart_product_medias.
I am trying to figure out a way fix this easily because my database is quite bit big (1000+ products, 4 images each).

I am trying to find a logical relation in order to make an sql query do the job for me.
It has to be between 3 tables.
virtuemart_product_medias that contains (id,virtuemart_product_id,virtuemart_media_id,ordering)
virtuemart_medias  fields I need: virtuemart_media_id, file title.
virtuemart_products fields I need: virtuemart_product_id,product_sku

Product Sku is same with the file title but with a small difference.
eg. sku is like 0010030 and file title is  like 0010030_xaaeaggaega or 0010030 ProductTitle or 0010030 a or 0010030 b or 0010030 C or 0010030 D.
I am interested only for the a b c d and A B C D images.

What i am thinking is to make an sql that adds to virtuemart_products_medias all virtuemart_media_id from virtuemart_medias where file_title is Like product_sku from virtuemart_products.

I am not sure if this works:
Insert Into virtuemart_product_medias (virtuemart_product_id,virtuemart_media_id) VALUES
((Select virtuemart_product_id from virtuemart_products where product_sku LIKE (Select file_title from virtuemart_media_id)),
(Select virtuemart_media_id from virtuemart_medias where file_title LIKE (Select product_sku from virtuemart_products))

I know the LIKE statemement is wrong and generally may have mistakes, if anyone can help i would be more than grateful.
I haven't figured out what to do about the ordering field, it needs to be 1,2,3 and 4 for each a b c d image.