CSV,将产品与其父级分组
CSV, Grouping Products with their parent
我有一个 CSV 文件,可用于将产品导入 Woocommerce。
它是从 Magento 生成的,我在将父产品与其子产品(变体)分组时遇到了严重的问题。父产品的类型为 "configurable",子产品的类型为 "simple",我终其一生都无法在两者之间找到任何唯一标识符,这将使我能够将子产品导入到他们的父产品中。
我注意到每个父产品 SKU 都以 00 结尾,并且每个子产品 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",
我看到你对 Open Refine Google group 提供了更详细的解释。
那么,您能否在 your dataset 上应用这些操作(使用 "Undo/Redo")并告诉我结果是否适合您?
[
{
"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], "")
我有一个 CSV 文件,可用于将产品导入 Woocommerce。
它是从 Magento 生成的,我在将父产品与其子产品(变体)分组时遇到了严重的问题。父产品的类型为 "configurable",子产品的类型为 "simple",我终其一生都无法在两者之间找到任何唯一标识符,这将使我能够将子产品导入到他们的父产品中。
我注意到每个父产品 SKU 都以 00 结尾,并且每个子产品 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",
我看到你对 Open Refine Google group 提供了更详细的解释。
那么,您能否在 your dataset 上应用这些操作(使用 "Undo/Redo")并告诉我结果是否适合您?
[
{
"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], "")