#Filter products using custom fields
12 messages · Page 1 of 1 (latest)
you can use patch-package if you use yarn 1 or yarn 3 to patch the medusa package. Add your custom fields to all the products.** files in the patch folder, something like that
Thanks for the hint. I'd prefer a solution that would allow extending an existing route. After messing around with this for a couple of weeks now, I think the approach to custom attributes in medusaJS is half baken at best. Something that takes minutes in other solutions takes days to figure out properly and it is concerning that patching source code is easier than trying to figure out how to do it properly. This should be much, much simpler.
have you figured out a way without patching ?
please in case you do let us know here
Unfortunately i can't spend any more time on this. Another option was brought up on GH discussions (using metadata and custom routes instead of attributes on the product entity itself)
Since I query and cache server side anyways, I decided to do filtering/pagination there as well until there is a better solution available.
If you don't want to patch the package, I think you can create an endpoint on the backend, it is able to retrieve custom fields using list method on the backend
This might be helpful: https://discord.com/channels/876835651130097704/1107352184607232100
This is about overriding the default relations that are included when retrieving a cart. But a similar approach could be applied for overriding the allowedfields when retreiving a list of products.