How to add new column from and exiting column using a parser funtion?
AnsweredHi
In my product feed, there is a column group_id with 12 digit codes.
Using the parser function, I want to create a new column which can only take the last 4 digits of the group_id.
Hope someone could help.
-
You can have a function running within the parser that extracts the last 4 digits, and point a new column to that function. For example, take a standard CSV upload with the 8 required column
function parse(data){
return data.map(function(prod) {
return {
sku: prod.sku,
name: prod.name,
categories: prod.categories,
group_id: prod.group_id,
price: prod.price,
in_stock: prod.in_stock,
url: prod.url,
image_url: prod.image_url,
keywords:prod.keywords,
last_four: getLAstFourDigits(prod.group_id)
}
})
}
function getLAstFourDigits(group_id){
return groupId.slice(-4);
}
Please sign in to leave a comment.
Comments
2 comments