VirtueMart Forum

VirtueMart 2 + 3 + 4 => Installation, Migration & Upgrade => Topic started by: raycarter on May 01, 2012, 17:34:52 PM

Title: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 01, 2012, 17:34:52 PM
EDIT - April 26, 2013

UTF8 languages support added.

------------------------------------------

Code is here:

url : http://tny.cz/ddc56f55
pass : vmuser

This is tested on VM 1.1.9 to VM 2.0.6 But ideally should work on all versions.

I wrote this non-professional import script for one of my sites.

How to import child products:

1. First Migrate all data from old virtuemart to new virtuemart.
2. Your database should contain old virtuemart products table (jos_vm_product) and new vm tables.
3. Copy the code from the above location and paste it into a notepad file. Name the file importer.php (change the file type to all) and place it in the joomla root.
4. Change the variable $oldtable value to your old virtuemart product table on line 9. In most cases it will be : jos_vm_product - Line#12
6.  Adjust settings (database, username etc) at the top of the script and access via url to execute it.
5. Add product ids to ignore (in case you already imported or added attributes to some products) - Line#13
$ignore = array(""); //array("11,12"); any products ids to ingore import to. ids are from new <yourdbprefix>_virtuemart_products  table.
6. RUN IT ONCE! (otherwise it will keep importing the attributes)

What it does:

NOTE : It migrates product attributes which are defined under the product status tab of a product in Old versions of Virtuemart. It imports attributes which have a parent property and then child attributes. The imported properties will become parents and will be assigned as CART VARIANTS. IF you want to change that behavior, look around line 70.

Let me know if there is any issues and i will fix it when i get time. Its pretty simple so any one can modify or improve it.

THIS IS NOT A PROFESSIONAL CODE. Just a quick fix.


It will make VM 1.1.9 Attributes defined like this :
(http://i47.tinypic.com/2ezokkz.png)

To this in the VM 2 frontend:
(http://i47.tinypic.com/4qkhug.png)
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Joe Bourque on May 02, 2012, 04:46:52 AM
Can you please explain what you mean by step 3? Copy the script and place it on top of the index file?

Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 02, 2012, 15:54:20 PM
Actually the code is Joomla based and requires Joomla to be loaded. So keep the code somewhere it can be executed. So your template's index file might be one place. Or any other file being loaded by Joomla.

I am sorry it had to be this way because i did not use native php functions for database access.

Title: Re: Partial Solution to Migration of Product Attributes
Post by: Joe Bourque on May 02, 2012, 15:55:41 PM
Ray,

So you are saying to copy the code to the top of my index page? I tried that and it did not work.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 02, 2012, 16:06:18 PM
I think you should wait for a while. i will update the code to be Joomla free. then you will be able to run it from the Joomla's main directory.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Joe Bourque on May 02, 2012, 16:44:20 PM
Thanks I just updated a site that has 3,000 products with shirt sizes I'm manually creating these attributes since the site is live. Any help is appreciated.

THanks for your help
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 02, 2012, 17:32:37 PM
I updated the code and instructions. If still any problems i will attend to them tomorrow.

please try this on a test site first.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: rickg123 on May 02, 2012, 21:53:50 PM
Hi,

Thanks for this script! I ran it on my site and have the following error. All attributes are migrated but the price is not, each attribute has different prices.

OLD SITE : http://www.rugboutique.co.uk/curly/curly-wool-rug-brown/flypage_images.tpl.html

NEW SITE : http://www.rugboutique.co.uk/jupgrade25/wool-rugs-for-sale/curly-rugs-curly-wool-rugs/brown-curly-wool-rug-detail.html

Just thought I'd let you know, there may be some changes you can make, either way this has still saved me a lot of time so thank you very much!
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 03, 2012, 01:39:20 AM
Kindly send your old vm_products table sql or type a table row here.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Joe Bourque on May 03, 2012, 02:27:03 AM
Ray you are a rock star.  This really saved me.  Like the last person said  the script parses the price and puts it into the 'Custom Value' instead of the Price.

I'm going through the database and correcting those items which is far less easier than manually updating the prices and sizes.

Thanks again for your assistance I really appreciate it.

Joe
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 03, 2012, 02:51:29 AM
Thank you Joe and Rick.

If the products are setup as shown in the first post then everything should work. You can modify the script around line 89 to tailor according to your database Or you could send me one example of the attributes field from the vm_products table and i will see what i can do to help.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: rickg123 on May 03, 2012, 03:58:08 AM
Hey Ray,

My attributes look like this:

Size,110 x 170cm[=104.17],140 x 200cm[=158.33],170 x 240cm - SOLD OUT[=208.33],200 x 300m - SOLD OUT[=283.33],250 x 350cm[=483.33]

You'll notice that the price is the final value price not an addition to the base price, does this change things?

On a different subject has anyone worked out how to migrate additional product images from old VM?

Cheers
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 03, 2012, 04:26:01 AM
The script is only handling the attributes which increase or decrease the cost of a product. You create your desired attribute in new Virtuemart and send me that entry from virtuemart_product_customfields table. I only have to parse '=' part in your old virtuemart attribute and make it a child product (or whatever it is called).
Title: Re: Partial Solution to Migration of Product Attributes
Post by: rickg123 on May 03, 2012, 11:22:35 AM
Sorry Ray I'm not sure what you mean. I am a complete noob to VM2, used to use VM1 a lot 1-2 years ago. If I used child products then each one can have independent stock qty's?

If you can possibly point me in the right direction?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 03, 2012, 14:54:23 PM
Hi Rick,

There are discussions going on about using child products with separate stock control, maybe you could jump to those and see what is the solution. I did not read those threads, if there is a solution then someone just needs to tell me how to set it up and i will then reflect it in the script.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: ereallstaff on May 04, 2012, 12:28:49 PM
Which extension do you use to filter products?

tanks
Title: Re: Partial Solution to Migration of Product Attributes
Post by: mdills on October 11, 2012, 16:38:37 PM
You are a godsend. Thank you for this.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: S. Nalepa on October 18, 2012, 18:28:48 PM
Kudos!

Great script! Just put it, after modification, in the Joomla!-root and ran by writing the script-name as address in the browser - and ta-daa! Attributes are put just where they should be!

I'm thinking rebuilding this script to an analogous import of all the extra-images - should be do-able, shouldn't it?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on October 19, 2012, 02:48:13 AM
Quote from: S. Nalepa on October 18, 2012, 18:28:48 PM
Kudos!

Great script! Just put it, after modification, in the Joomla!-root and ran by writing the script-name as address in the browser - and ta-daa! Attributes are put just where they should be!

I'm thinking rebuilding this script to an analogous import of all the extra-images - should be do-able, shouldn't it?

Should be. Yes. 

The script is not complete. It only brings straightforward attributes like shown in the original post. There are other attributes in virtuemart which are defined with an "=" sign (see below) and i do not know how they should look like in new virtuemart. This is something you could improve upon.

Attribute type not working yet = Size,110 x 170cm[=104.17],140 x 200cm[=158.33]

Title: Re: Partial Solution to Migration of Product Attributes
Post by: betterlead on October 19, 2012, 08:38:57 AM
Quote from: S. Nalepa on October 18, 2012, 18:28:48 PM
Kudos!

Great script! Just put it, after modification, in the Joomla!-root and ran by writing the script-name as address in the browser - and ta-daa! Attributes are put just where they should be!

I'm thinking rebuilding this script to an analogous import of all the extra-images - should be do-able, shouldn't it?

Keeping my fingers crossed and hoping for a solution. Could save hundreds of hours of work.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: patrick356356 on October 21, 2012, 10:12:55 AM
Yes, I agree. Anybody who can solve the issue that migration doesn't migrate additional images (and other additional files) will be my hero!
Title: Re: Partial Solution to Migration of Product Attributes
Post by: saviB on October 23, 2012, 21:59:39 PM
Thank you raycarter

I could really use this too! My attributes are product variants - like color, type of bead, etc. I ran the importer - but I don't believe it worked for my set up. However - there are now custom fields.

raycarter, I'd be happy to pay if you could take a look at my set up and see if we can automate adding the attributes. And, I'm fine with posting the work for all to use. It would help very much if you had a solution for migrating the additional images too! Just PM me if you are interested.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: infin8 on November 02, 2012, 21:59:04 PM
What a LEGEND!  Just imported attributes for over 1300 products! Thanks mate  8)
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on November 13, 2012, 15:30:02 PM
My apologies i didnt check the site in a while and couldn't answer any private messages that i received but perhaps i dont have time to work for anyone. I am doing this to help people.

I can find some time this weekend but i need a live example of how those child products (which are not being imported by this script) would be setup in new virtuemart (site url and the database tables for both old and new virtuemart) and i will try to automate it.
This is what i want to do first. If examples are provided with additional images etc, i will perhaps do that too.

I hope those who build upon this script will not use it for profit. It should be free.


Quote from: saviB on October 23, 2012, 21:59:39 PM
Thank you raycarter

I could really use this too! My attributes are product variants - like color, type of bead, etc. I ran the importer - but I don't believe it worked for my set up. However - there are now custom fields.

raycarter, I'd be happy to pay if you could take a look at my set up and see if we can automate adding the attributes. And, I'm fine with posting the work for all to use. It would help very much if you had a solution for migrating the additional images too! Just PM me if you are interested.
With regards to additional images, Does this not work for you? http://forum.virtuemart.net/index.php?topic=109502.0

Title: Re: Partial Solution to Migration of Product Attributes
Post by: saviB on November 14, 2012, 20:09:07 PM
QuoteWith regards to additional images, Does this not work for you? http://forum.virtuemart.net/index.php?topic=109502.0

OUTSTANDING! Werian, this is such a great thing you have done for us. Note to other users, after installation, you need to ENABLE the plugin through the plugin manager. Just search for: Images migrator from VM1 to VM2 and click the red dot.

Raycarter, thank you too, for bringing this to my attention. I have since updated all the attributes in that site - but I may need help in the future. I have another 10 sites to convert... Sigh... PM me if you are interested in VM work. I need a few modifications I would like to discuss.

Title: Re: Partial Solution to Migration of Product Attributes
Post by: Spiros Petrakis on January 16, 2013, 13:01:42 PM
Hi raycarter great job a must have tool .
I have only one problem all the attributes migrating to vm2 but because i use Greek language for some of them they display like this ? ? ? ? ? ?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: haidamaka on April 25, 2013, 20:24:59 PM
It`s excellent solution. Thank you so much!!!
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on April 26, 2013, 18:46:52 PM
Quote from: yourgeek on January 16, 2013, 13:01:42 PM
Hi raycarter great job a must have tool .
I have only one problem all the attributes migrating to vm2 but because i use Greek language for some of them they display like this ? ? ? ? ? ?

I have updated the code. test and reply.


Quote from: haidamaka on April 25, 2013, 20:24:59 PM
It`s excellent solution. Thank you so much!!!

I am glad it worked for you. :)
Title: Re: Partial Solution to Migration of Product Attributes
Post by: wnrdesign on May 10, 2013, 14:51:19 PM
Hi Ray Carter,

Great script! I've imported all the product options. There is only 1 problem.

The prices are set in the virtuemart value like this: SS Performance street disc[+24.37]
The price is not copied to the price tab

These are the values:

Value: SS Performance street disc[+24.37]
Price: 0.000

Any suggestions.

Kind regards,
Wouter


NOTE: I've managed to find out the problem, i've exported the product attributes to a csv file via phpmyadmin and managed to find out there where a few rows corrupted. Fixed those rows and imported via phpmyadmin again, and voila! It worked



[attachment cleanup by admin]
Title: Re: Partial Solution to Migration of Product Attributes
Post by: hoseonline on May 14, 2013, 10:00:35 AM
Hi,
it doesnt run.
When I start the script it says
Connted to DB - Beginning operation

INSERT INTO jos__virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
        ('Größe',"","V","1","1")
all end

There are no attributes in the new tables of VM2.

Can you help?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 15, 2013, 17:26:08 PM
Quote from: hoseonline on May 14, 2013, 10:00:35 AM
Hi,
it doesnt run.
When I start the script it says
Connted to DB - Beginning operation

INSERT INTO jos__virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
        ('Größe',"","V","1","1")
all end

There are no attributes in the new tables of VM2.

Can you help?

Did you adjust the configurations in the beginning of the code?
The new database name, the old database name.

Also make sure old database tables are present side by side the new tables.

Title: Re: Partial Solution to Migration of Product Attributes
Post by: vragec on May 16, 2013, 18:06:25 PM
Hi,

Great script, but it doesnt work for me.

It writes out message:


Connted to DB - Beginning operation



Warning:  mysql_result() expects parameter 1 to be resource, boolean given in /home/ortopeds/public_html/xxxx/xxxx/importer.php on line 132



Warning:  mysql_result() expects parameter 1 to be resource, boolean given in /home/ortopeds/public_html/xxxx/xxxx/importer.php on line 132

INSERT INTO j25_virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
        ('Barva',"","V","1","1")
all end



Any ideas?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on May 20, 2013, 06:09:15 AM
Quote from: vragec on May 16, 2013, 18:06:25 PM
Hi,

Great script, but it doesnt work for me.

It writes out message:


Connted to DB - Beginning operation



Warning:  mysql_result() expects parameter 1 to be resource, boolean given in /home/ortopeds/public_html/xxxx/xxxx/importer.php on line 132



Warning:  mysql_result() expects parameter 1 to be resource, boolean given in /home/ortopeds/public_html/xxxx/xxxx/importer.php on line 132

INSERT INTO j25_virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
        ('Barva',"","V","1","1")
all end



Any ideas?

Hi, its unfortunate that it didnt work. Can you follow the last post and tell me if you made sure that all new and old tables were in place? and you already imported the products to new VM.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: jgentles on June 11, 2013, 17:48:24 PM
Thank you very much for this solution. It worked perfectly for me and saved me so much time. Thank you! Thank you! Thank you!

Janice Gentles-Jones
JGJ Consulting
www.onlinesuccessmap.com
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Milbo on June 14, 2013, 15:06:27 PM
Looks good. I took the code and added it to the core, to the migrations tab. But I cannot test it. The code is just roughly added and made working with the joomla db. It would be cool if someone could enhance it in future there, so it is directly in the code :-) Please check 2.0.21E http://dev.virtuemart.net/projects/virtuemart/files
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on June 15, 2013, 22:51:42 PM
Quote from: Milbo on June 14, 2013, 15:06:27 PM
Looks good. I took the code and added it to the core, to the migrations tab. But I cannot test it. The code is just roughly added and made working with the joomla db. It would be cool if someone could enhance it in future there, so it is directly in the code :-) Please check 2.0.21E http://dev.virtuemart.net/projects/virtuemart/files

Hello Milbo. Thats a good news.  But i dont see any 2.0.21E yet.


I had done this script for one of my sites and thought i would share it. The script is not complete and is missing atleast 2 things:

1. it shouldnt keep importing attributes over and over again if ran more than once.

2. Someone asked before that how could they import attributes defined like the following :

Size,110 x 170cm[=104.17],140 x 200cm[=158.33],170 x 240cm - SOLD OUT[=208.33],200 x 300m - SOLD OUT[=283.33],250 x 350cm[=483.33]

You'll notice that the price is the final value price not an addition to the base price and i have not handled this in my code. I can do this if i only i knew what such products become in Virtuemart 2.  Do they become cart variants?


Let me know if there is anything else that i missed and i will do it.

Thanks

Title: Re: Partial Solution to Migration of Product Attributes
Post by: Milbo on June 16, 2013, 20:00:24 PM
Here http://forum.virtuemart.net/index.php?topic=115877.0

We had this code also already in the migrator, but it was leading to errors sometimes. So I think it is better to have it in independend tasks. Your function is in the BE/helpers/migrator.php. At the end of the line is your function. I just added the resume, please check it. It would be also nice if someone debugs the migrate related products solution.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Milbo on June 26, 2013, 23:02:03 PM
Please test http://forum.virtuemart.net/index.php?topic=115877.0 Version G is now also importing the values correctly. But we had to drop the =values, because they make not really sense (would just change the baseprice)
Title: Re: Partial Solution to Migration of Product Attributes
Post by: raycarter on August 08, 2013, 03:52:58 AM
Quote from: Milbo on June 26, 2013, 23:02:03 PM
Please test http://forum.virtuemart.net/index.php?topic=115877.0 Version G is now also importing the values correctly. But we had to drop the =values, because they make not really sense (would just change the baseprice)

I had started to work on it to improve the code. i had fixed it for + and - scenario. I worked on the = case as well but according to my knowledge those are child products (if i am not wrong). so one can create child products out of them. i wrote some more code and then left the country for some days and could never get back to it.
I will come back to it soon and share my code.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: _dj on September 17, 2013, 13:41:16 PM
Your code is working fine for "Attribute List" but for "Custom Attribute List" it doesn't working. Will you please add some code or comments to make this.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: _dj on September 17, 2013, 14:39:50 PM
One more thing, after selecting "Attribute List" the price is not updated according to the selected items, in the cart.
As in attached pics. pic 11 shows the old version attribute list and pic 10 shows the updated one but haven't migrate price. Please have a look on it.

[attachment cleanup by admin]
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Maxim Pishnyak on September 17, 2013, 17:16:34 PM
CSVI Improved is the way to go.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: _dj on September 18, 2013, 08:52:42 AM
raycarter i'm waiting for your reply. Please give me way how i can use your code to migrate "Custom Attribute List".
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Maxim Pishnyak on September 18, 2013, 08:59:01 AM
Quote from: Maxim Pishnyak on September 17, 2013, 17:16:34 PM
CSVI Improved is the way to go.
Why even don't try proposed solution? Solution which will be supported for you by VM and CSVI strong support forums?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: _dj on September 18, 2013, 10:48:12 AM
Maxim Pishnyak my client doesn't want any paid extension. Everything has been migrated. Just for Custom attribute i have to purchase a new extension. That doesn't make any sense.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Maxim Pishnyak on September 18, 2013, 19:58:25 PM
Quote from: _dj on September 18, 2013, 10:48:12 AM
Maxim Pishnyak my client doesn't want any paid extension.
DJ about what are you talking about?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: _dj on September 19, 2013, 09:27:17 AM
i checked the extension you told me. but i was not successful to migrate my custom attribute list. Is there is any tutorial for this.
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Maxim Pishnyak on September 19, 2013, 22:12:46 PM
I see. http://forum.virtuemart.net/index.php?topic=118844.msg403819#msg403819
You could make CSVI export custom fields data in VM2 for learning purpose. CSVI Improved web site has tutorials. Did you check them?
Title: Re: Partial Solution to Migration of Product Attributes
Post by: Kintaro Oe on June 10, 2014, 16:55:45 PM
Quote from: hoseonline on May 14, 2013, 10:00:35 AM
Hi,
it doesnt run.
When I start the script it says
Connted to DB - Beginning operation

INSERT INTO jos__virtuemart_customs (custom_title,custom_tip,field_type,is_cart_attribute,published) VALUES
        ('Größe',"","V","1","1")
all end

There are no attributes in the new tables of VM2.

Can you help?

for me the problem was the prefix, you have to set it on the top configuration of the importer.php without the "_" (underscore).

I know it's old but those questions was unanswered ;)