#Importing list products don't associate the product to a collection

18 messages · Page 1 of 1 (latest)

gritty kelp
#

Hi again, finally I could import list using CSV file.

But now I have a problem, when I import a product it doesn't appear associated to its collection.

At the CSV file I write down in the columns "Product collection title" and "Product collection handle" the title and the handle of a collection which I've created previously.

steady ivy
#

Have this issue as well, curious how you got past the import issue?

Does this issue resolve if you create the collection beforehand in Medusa?

gritty kelp
#

Hi NathanNye, It's working using latest version of Medusa core and admin (git pull) medusa-file-minio-temp.

gritty kelp
#

And no, I created the collection before but it doesn't resolve it

steady ivy
#

Ah damn, I'll have to look into the collections thing more once this starts working then. Ive got all the latest on core and admin after a pull, I am using spaces however, also up to date. I am noticing my db (postgres) has all the demo products in it even after they have been deleted from the admin side. I flushed redis db and all as well. Stumped

Now seeing a core error for computerizeAmount when importing

gritty kelp
#

@leaden wing @muted fox any ideas?

gritty kelp
#

I've been investigating about it and these are my conclusions:

#

When the batchjob process product-import it's called product-service. there at the method create process the productObject proccessed from each row from csv file and them create the product through the product repository.

#

In my case, if I add the column of Product Collection Title and Product Collection Handle add this line to the json .
collection: ProductCollection { title: "MEDICAMENTOS", handle: "MEDICAMENTOS }

The result is that the product it's not associated to the collection.

But if I change that to NULL and add this at the CASE 2 (:
product_1.collection_id = 'pcol_01GFGE70DG2BATXVJPY8E8NQ0G';

it works.

shadow wigeon
#

What JSON are you referring to? @gritty kelp

#

I have same issue

shadow wigeon
#

I ended up using Tags as a make do solution

gritty kelp
#

It's the JSON which is generated in the Product Service. I've been testing in the dist files. Tomorrow I'll fork the repo and try a better solution in the source code

gritty kelp
#

I fixed writting the collection id instead of the title at Product Collection Title column in the csv file

#

@leaden wing may I create a branch and pull request?

leaden wing
#

Yes sure 🎉

gritty kelp
gritty kelp
#

Hi again, I made a new pull request which checks if the collection exists at import strategy (/medusa/src/strategies/batch-jobs/product/import.ts ).

If it doesn't exist then it's created the collection and passes the collection_id to ProductService.

If it's created already just get the collection id and it's passed to ProductService.

To work it's needed to delete the attribute collection from ProductData, and for that I needed to add the attribute collection?: {} to the type CreateProductInput