Skip to content

Commit 0786138

Browse files
committed
fix(cli): Ensure SKU as strings on feed import
1 parent 079222e commit 0786138

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/cli/src/ext/import-feed.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const mapCSVToFeed = (item: CSVItem): FeedItem => {
157157
const canManageStock = item['controlar-estoque'] !== 'N';
158158
const quantity = Number(item['estoque-quantidade']) || 0;
159159
return {
160-
'g:id': item.sku,
160+
'g:id': `${item.sku}`,
161161
'g:title': item.nome,
162162
'g:description': item['descricao-completa'] || item['seo-tag-description'],
163163
'g:image_link': item['imagem-1'],
@@ -211,8 +211,14 @@ const importFeed = async () => {
211211
attributeNamePrefix: '',
212212
});
213213
const json = parser.parse(fs.readFileSync(argv.feed, 'utf8'));
214-
_items = json.rss?.channel?.item?.filter?.((item: any) => {
215-
return item?.['g:id'] && item['g:title'];
214+
json.rss?.channel?.item?.forEach?.((item: any) => {
215+
if (item?.['g:id'] && item['g:title']) {
216+
item['g:id'] = `${item['g:id']}`;
217+
if (item['g:item_group_id']) {
218+
item['g:item_group_id'] = `${item['g:item_group_id']}`;
219+
}
220+
_items.push(item);
221+
}
216222
});
217223
} else if (fileExtension === '.tsv') {
218224
const csvContent = fs.readFileSync(feedFilepath, 'utf8');

0 commit comments

Comments
 (0)