Use Excel/VB to create a list of product variations based on list of parent products -



Use Excel/VB to create a list of product variations based on list of parent products -

i running woocommerce shop product csv import suit plugin. need first upload list parent products , sec list products variations. creating sec list quite labor intensive, looking way automatically generate list much possible.

here how short, simplified list of parent products like:

the actual list parent products contain many more product characteristics.

and how results product variations should like:

as see can see product variation (child) inherents of products characteristics of parent product , 1 of size , color variables. nice if kid sku automatically generated well.

i output info (product variations) generated in different worksheet (seperate parent product list).

does have thoughts how in excel? no excel wizard, hope can give me guidance on how implement solution.

the logic here read each row until empty row found, , split colors , sizes. create outer loop colors , inner loop sizes (this process variations). need variable hold kid sku counter , reset when variation done product. next started:

sub productvariations() dim productrow long, variationrow long dim size string dim color string dim skucounter integer dim skuchild string dim sizearray() string dim colorarray() string dim sizeelement variant dim colorelement variant dim productssheet worksheet dim variationssheet worksheet productrow = 2 variationrow = 2 set productssheet = activeworkbook.sheets(1) set variationsheet = activeworkbook.sheets(2) 'loop through each row until blank row found while productssheet.cells(productrow, 1).value <> "" 'get size , color values current row size = productssheet.cells(productrow, 3) color = productssheet.cells(productrow, 4) 'make sure size , color exists process if len(size) > 0 , len(color) > 0 'reset sku counter skucounter = 0 'split size , color arrays sizearray = split(size, "|") colorarray = split(color, "|") 'loop through each size each sizeelement in sizearray 'loop through each color each colorelement in colorarray 'increment kid counter variation skucounter = skucounter + 1 'set appropriate cells in variations sheet (you have more work here skuchild = productssheet.cells(productrow, 2).value & "-" & skucounter variationsheet.cells(variationrow, 1).value = productssheet.cells(productrow, 1) variationsheet.cells(variationrow, 3).value = skuchild 'increment variation row next variation goes in next row variationrow = variationrow + 1 next colorelement next sizeelement end if 'very of import increment next row or first row ever processed productrow = productrow + 1 wend end sub

excel excel-vba woocommerce

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -