我有一个CSV文件,该文件将用于将产品导入Woocommerce。
它是从Magento生成的,我在将父产品与孩子(变体)分组时遇到了很大的麻烦。父产品的类型为“可配置”,子产品的类型为“简单”,我一生无法找到两者之间的唯一标识符,这会使我将子产品导入其父产品中。
我注意到每个父产品SKU以00结尾,并且对于每个子产品SKU递增01、02、03,并且我注意到每个父产品名称与子产品非常相似,但例外添加的变化属性(例如颜色等)的颜色-黑色,-蓝色,-红色等在SKU或产品名称上如此相似,是否可能?
我认为必须使用OpenRefine。
以下是一些示例数据,如果您对我可以将两者结合使用的方法有任何想法,请随时进行阐述。
ProductNo,Sku,Type,Product_name,Product_description,Price,CreatedDate,Status,categories
32,VIS00500,configurable,"Spinner II Battery","Batterycapacity: 1650mah",
33,Vis00501,simple,"Spinner II Battery - Black","Spinner II Battery - Black",0.0000,2014-10-02,Enabled,"Shop by Brand>Vision>Batteries and MODs",
这是另一个,展示了我希望实现的目标:
ProductNo,ParentID,Sku,Type,Product_name,Product_description,Price,CreatedDate,Status,categories
32,VIS00500, ,configurable,"Spinner II Battery","1650mah",14.1800,2014-10-02,Enabled,"Shop by Brand>Vision>Batteries and MODs",
33,Vis00501,32,simple,"Spinner II Battery - Black","Spinner II Battery - Black",0.0000,2014-10-02,Enabled,"Shop by Brand>Vision>Batteries and MODs",
答案 0 :(得分:0)
我看到您在Open Refine Google group上提供了更详细的说明。
那么,您可以在your dataset上应用这些操作(使用“撤消/重做”),并告诉我结果是否适合您吗?
[
{
"op": "core/row-reorder",
"description": "Reorder rows",
"mode": "row-based",
"sorting": {
"criteria": [
{
"errorPosition": 1,
"caseSensitive": false,
"valueType": "string",
"column": "Sku",
"blankPosition": 2,
"reverse": false
}
]
}
},
{
"op": "core/column-addition",
"description": "Create column isparent at index 2 based on column Sku using expression grel:if(value.match(/(.+00$)/).length() > 0, \"parent\", \"\")",
"engineConfig": {
"mode": "row-based",
"facets": []
},
"newColumnName": "isparent",
"columnInsertIndex": 2,
"baseColumnName": "Sku",
"expression": "grel:if(value.match(/(.+00$)/).length() > 0, \"parent\", \"\")",
"onError": "set-to-blank"
},
{
"op": "core/column-move",
"description": "Move column isparent to position 0",
"columnName": "isparent",
"index": 0
},
{
"op": "core/column-addition",
"description": "Create column parent at index 3 based on column Sku using expression grel:if(row.record.cells.Sku.value[0] != value, row.record.cells.Sku.value[0], \"\")",
"engineConfig": {
"mode": "row-based",
"facets": []
},
"newColumnName": "parent",
"columnInsertIndex": 3,
"baseColumnName": "Sku",
"expression": "grel:if(row.record.cells.Sku.value[0] != value, row.record.cells.Sku.value[0], \"\")",
"onError": "set-to-blank"
}
]
如果您喜欢人类的解释:
1°按升序(a-z)将列“ Sku”排序为文本。永久重新排序行
2°使用以下Grel公式,在“ Sku”列的基础上创建“ isparent”列,并将此新列移至开头:
if(value.match(/(.+00$)/).length() > 0, "parent", "")
3°使用此Grel公式基于“ Sku”创建新列“ parent_id”:
if(row.record.cells.Sku.value[0] != value, row.record.cells.Sku.value[0], "")