VirtueMart Forum

VirtueMart 2 + 3 + 4 => Installation, Migration & Upgrade => Topic started by: Thong Tran on September 09, 2012, 14:07:25 PM

Title: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: Thong Tran on September 09, 2012, 14:07:25 PM
Hi guys,

I've migrated from VM 1.1.9 to 2.0.10, everything went fine. But I got married with a problem with product_id.
The "virtuemart_product_id" in "virtuemart_products" table changed, it is different with the old product_id from "vm_product". I don't know if anyone got the same issue with that, and how to fix it?
I've tried some search on the forum but can't find the answer.

Please advise if I didn't something wrong or it is an unknown issue.

Best Regards,
Thong Tran
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: Thong Tran on September 10, 2012, 10:42:24 AM
I see Milbo is fixing it on SVN. Is that right, Milbo?

Just want to know if I'm not alone with that issue.
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: Milbo on September 12, 2012, 00:39:33 AM
You can use in the new version a variable, which you must set in the configuration.ini and then you use in the tools the config restore thing. Then you should have that in the config and the migrator should use old ids, but I recommend new ids, hmm I should add the option
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: Thong Tran on September 13, 2012, 05:46:41 AM
Quote from: Milbo on September 12, 2012, 00:39:33 AM
You can use in the new version a variable, which you must set in the configuration.ini and then you use in the tools the config restore thing. Then you should have that in the config and the migrator should use old ids, but I recommend new ids, hmm I should add the option

Thanks for your reply, Milbo. I can't find anywhere the file configuration.ini, can you please provide more details instruction?
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: manburg6 on March 31, 2013, 23:26:20 PM
Any news about this info???

I need to mantain old product_id for seo purpose.

Thanks,
M.
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: manburg6 on April 02, 2013, 00:19:31 AM
Hello,

this is my script to change, after migration, product_id.
I have both tables (old 1.1.9 and new 2.0.20) in same db with diferent prefix: jos and j25.


UPDATE j25_virtuemart_order_items SET j25_virtuemart_order_items.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id = j25_virtuemart_order_items.virtuemart_product_id));

UPDATE j25_virtuemart_product_medias SET
j25_virtuemart_product_medias.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id =
j25_virtuemart_product_medias.virtuemart_product_id));

UPDATE j25_virtuemart_product_prices SET
j25_virtuemart_product_prices.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id =
j25_virtuemart_product_prices.virtuemart_product_id));


CREATE TABLE j25_virtuemart_product_categories_new AS
SELECT * FROM j25_virtuemart_product_categories;

UPDATE j25_virtuemart_product_categories_new SET j25_virtuemart_product_categories_new.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id = j25_virtuemart_product_categories_new.virtuemart_product_id));

Delete from j25_virtuemart_product_categories;

Insert into j25_virtuemart_product_categories select * from j25_virtuemart_product_categories_new;

DROP TABLE j25_virtuemart_product_categories_new;


CREATE TABLE j25_virtuemart_product_manufacturers_new AS
SELECT * FROM j25_virtuemart_product_manufacturers;

UPDATE j25_virtuemart_product_manufacturers_new SET j25_virtuemart_product_manufacturers_new.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id = j25_virtuemart_product_manufacturers_new.virtuemart_product_id));

Delete from j25_virtuemart_product_manufacturers;

Insert into j25_virtuemart_product_manufacturers select * from j25_virtuemart_product_manufacturers_new;

DROP TABLE j25_virtuemart_product_manufacturers_new;


CREATE TABLE j25_virtuemart_products_it_it_new AS
SELECT * FROM j25_virtuemart_products_it_it;

UPDATE j25_virtuemart_products_it_it_new SET j25_virtuemart_products_it_it_new.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = (SELECT product_sku FROM j25_virtuemart_products Where j25_virtuemart_products.virtuemart_product_id = j25_virtuemart_products_it_it_new.virtuemart_product_id));

Delete from j25_virtuemart_products_it_it;

Insert into j25_virtuemart_products_it_it select * from j25_virtuemart_products_it_it_new;

DROP TABLE j25_virtuemart_products_it_it_new;



CREATE TABLE j25_virtuemart_products_new AS
SELECT * FROM j25_virtuemart_products;

UPDATE j25_virtuemart_products_new SET j25_virtuemart_products_new.virtuemart_product_id = (
SELECT jos_vm_product.product_id FROM jos_vm_product WHERE jos_vm_product.product_sku = j25_virtuemart_products_new.product_sku);

Delete from j25_virtuemart_products;

Insert into j25_virtuemart_products select * from j25_virtuemart_products_new;

DROP TABLE j25_virtuemart_products_new;



I've tested it and weems to works.

I'm working on conversion script for product relations and reviews...

Bye,
M.
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: AH on January 27, 2014, 15:36:34 PM
Nice post, thanks for taking the time to let others know!

I would use TRUNCATE to remove all entries as this resets the AUTO_increment values

rather than DELETE FROM #_table_name


However the migrator.php should allow this - why was it necessary to "force" the id change?

Some shops will utilise this id for internal purposes
Title: Re: Migrate from 1.1.9 to 2.0.10, product_id changed
Post by: Kintaro Oe on May 06, 2014, 16:28:03 PM
same problem here

I'm testing the migration from 1.1.9 to 2.6 but product_ids change, I need that remain the same.

I'm going to try manburg6's way... I have to change it for VirtueMart 2.6?

Regards


p.s. in the meantime i SOLVED with this: http://forum.virtuemart.net/index.php?topic=121624.msg415847#msg415847