shahednasser / medusa-1.8-marketplace-tutorial

Code for creating a marketplace with Medusa v1.8
https://medusajs.com/blog/extending-medusa-usecase-marketplace/
46 stars 12 forks source link

TypeError: productRepo.findWithRelationsAndCount is not a function #8

Open ismetismetismet opened 7 months ago

ismetismetismet commented 7 months ago

Selam @shahednasser,

I am attempting to execute everything as explained in the documentation, but I've encountered an issue that I cannot resolve. It seems to be specific to Medusa version 1.20.0:

wilixResolutionError: Could not resolve 'loggedInUser'.

Resolution path: loggedInUser
    at resolve (/Users/korabh/git//node_modules/awilix/lib/container.js:252:23)
    at Object.get (/Users/korabh/git//node_modules/awilix/lib/container.js:66:33)
    at new ProductService (/Users/korabh/git//dist/services/product.js:30:39)
    at container.register._f.<computed>.lifetime (/Users/korabh/git//node_modules/@medusajs/medusa/dist/loaders/plugins.js:547:112)
    at Object.resolve (/Users/korabh/git//node_modules/awilix/lib/resolvers.js:295:20)
    at resolve (/Users/korabh/git//node_modules/awilix/lib/container.js:287:41)
    at Object.get (/Users/korabh/git//node_modules/awilix/lib/container.js:66:33)
    at new CartService (/Users/korabh/git//node_modules/@medusajs/medusa/dist/services/cart.js:130:259)
    at /Users/korabh/git//node_modules/@medusajs/medusa/dist/loaders/services.js:26:82
✔ Subscribers initialized – 4ms
✔ API initialized – 12ms
⠋ Initializing defaults
warn:    You don't have any notification provider plugins installed. You may want to add one to your project.
✔ Defaults initialized – 22ms
⠋ Initializing search engine indexing
✔ Indexing event emitted – 1ms

and once the app is running:

error:   productRepo.findWithRelationsAndCount is not a function
TypeError: productRepo.findWithRelationsAndCount is not a function
    at ProductService.<anonymous> (/Users/git/medusa/node_modules/@medusajs/medusa/dist/services/product.js:211:58)

Any ideas on how to resolve this issue?

Thank you!

ismetismetismet commented 7 months ago

I also changed Lifetime.TRANSIENT to Lifetime.SCOPED, but it did not work.

ReyhanDiansa commented 6 months ago

i have the same error productRepo.findWithRelationsAndCount is not a function, does anyone know the solution?

YishaqG commented 6 months ago

@ReyhanDiansa take a look to https://github.com/medusajs/medusa/issues/6139

magicxie commented 4 months ago

export const ProductRepository = dataSource .getRepository(Product) .extend( Object.assign( MedusaProductRepository, { target: Product } ), )

remove {...}

KabyleBOT commented 1 month ago

export const ProductRepository = dataSource .getRepository(Product) .extend( Object.assign( MedusaProductRepository, { target: Product } ), )

But this would override the repo, in case of using it in an other plugin !