File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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' ) ;
You can’t perform that action at this time.
0 commit comments