VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: phil147 on January 26, 2020, 12:26:56 PM

Title: Want to populate SKU field with ascending data...PHP or SQL?
Post by: phil147 on January 26, 2020, 12:26:56 PM
running VM 3.2.12 and Joomla 3.9.12

I'm using ro csvi extension to export my VM data to use in another website.

I have over 1000 products that unfortunately none have SKU data. ro csvi needs SKU to export/import correctly ( uses it in at least 2 database tables, vm_products, vm_product_media

I've searched for solutions to add data using SQL and PHP but cant get solution so far.

Eg I could make SKU = "xxx" and example use the virtuemart product id to create unique SKU.

I can access product data from VM with $product_model = VmModel::getModel('product');   and $myproduct = $product_model->getProduct($x);

Are there commands in VM to write back to the database with PHP? I was thinking to look in admin product view, and set SKU from there ?

Anyone know how to do this please?
Title: Re: Want to populate SKU field with ascending data...PHP or SQL?
Post by: GJC Web Design on January 26, 2020, 14:40:42 PM
why not export your csv, open in Excel or Open office, add your skus there
Title: Re: Want to populate SKU field with ascending data...PHP or SQL?
Post by: phil147 on January 26, 2020, 16:27:19 PM
yes you are right, i did add the sku's in excel but the extension ro csvi is throwing up conflicts when i import the file.....

I think its partly down to me missing out on some detail and the extension itself not as user friendly as it appears....

Originally i was just using Phymyadmin to migrate VM,main issues I was having was conflicts with the menu tables (i'm importing all menu items > 120)  so I was using ro csvi to export/import menu's and keep parity with menu tables...

ready to throw towel at it!!


Title: Re: Want to populate SKU field with ascending data...PHP or SQL?
Post by: Studio 42 on January 27, 2020, 01:42:39 AM
phil147, my tool vm Be Pro can import without SKU.
You can choose alias or name.
Of course the field need to be unique else you can have conflict too.
See https://shop.st42.fr/en/products/vm-be-pro-batch-product-edit.htm
Title: Re: Want to populate SKU field with ascending data...PHP or SQL?
Post by: PRO on January 27, 2020, 21:21:26 PM
why not use php my admin to set the sku field to the product id?


update _virtuemart_products
set product_sku = virtuemart_product_id