#Overriding the prepareListQuery method

9 messages · Page 1 of 1 (latest)

zenith socket
#

Im trying to modify the prepare list query method from medusa's core but it seems its a protected method ...I want to be able to filter products by the currently logged in user so id love to add the store id to the selector....how can i achieve this

sage burrow
#

You can prepare your selector instead of doing it during or after

zenith socket
#

perfect thanks

zenith socket
#

im trying to fetch the products of the currently logged in user .... when i send a get request to admin/products i still get all the products rather than it being specific to a user.... i put some consolelogs in the preparelistquery and prepareselectorconfig methods to confirm they are being called but they dont show up...dont know if im writing it correctly... but this is from the docs

sage burrow
#

Because the name is incorrect, it is prepareListQuery_

#

You can see that by looking the product service. What I often say, if you want to customise something wothin the core, you have to be able to look at the implementation and understand what you are trying to change. The risk without doing that is that I give you all the answers but you will never understand the why behind

zenith socket
#

yh iv been doing that ...but you know there'd be some gotchas lol...interesting implementation decisions too 🙌

sage burrow
#

Yes indeed 😊 I invite you to look around the service to see how it works and get a better idea of what you need to do. I suggest to do as less as possible override of the methods in favour (when possible) to just intercept and mutate the arguments . That way it is easier to upgrade and follow the changes