News:

Looking for documentation? Take a look on our wiki

Main Menu

Partial Solution to Migration of Product Attributes

Started by raycarter, May 01, 2012, 17:34:52 PM

Previous topic - Next topic

raycarter

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 :


To this in the VM 2 frontend:

Joe Bourque

Can you please explain what you mean by step 3? Copy the script and place it on top of the index file?


raycarter

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.


Joe Bourque

Ray,

So you are saying to copy the code to the top of my index page? I tried that and it did not work.

raycarter

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.

Joe Bourque

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

raycarter

#6
I updated the code and instructions. If still any problems i will attend to them tomorrow.

please try this on a test site first.

rickg123

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!

raycarter

#8
Kindly send your old vm_products table sql or type a table row here.

Joe Bourque

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

raycarter

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.

rickg123

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

raycarter

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).

rickg123

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?

raycarter

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.