#RemoteQuery - filter by linked table
1 messages · Page 1 of 1 (latest)
This cross-module filtering/sorting will come in a few weeks as another module (Index).
At the moment you will have to start querying by your custom module and expand products, or 2 queries.
@robust yacht Any idea when the cross-module filtering will be released? Also, Can you give an example of the workaround you mentioned above?
I have solved it by creating my own custom products endpoint (/store/custom-products), it fetches all products and variants including calculated price and then performs filters and sorting using javascript before responding with the edited list. Simple, easy. I will cache the products in the future if this needs to go to production
can you provide example?
Sure! This is my entire route.ts linked below. Im building a single language/currency commerce so I have the values defaulted at 65 and 66. Edit as needed or send own values using query params (it does not support region.id). Edit fields on line 77 as needed, you can then see data by console logging on 88 and perform your own logic. SortProducts method is stolen from the nextjs starter template and that is why the data type is overwritten on line 100. But it should be pretty much the same as a store product 🙂 What I like about this is that I dont need to sort my products in my storefront
This is an example call:
API/store/custom-products?limit=12&skip=0&sortBy=created_at
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@native copper Thanks for this, I have also implemented the same but my only worry is that pagination would break with this approach when certain products are filtered out by the filter method in js. I'm not using pagination for my custom route as of now but that's something to solve for production
I cannot implement search by first name and last name in order->customer and order->shipping_address, any suggestions?
I have no pagination yet in my storefront so it untested. As long as we have all products in products I think pagination should work? One thing I just realized my count is wrong. It needs to be stored before the slice at #98 so pagination wouldnt work with my example either way.
@native copper any suggestions for search/filtering in customer and shipping address of an order like this?
Whats $ilike? Isnt the operator just $like ?
it is for ignoring uppercase
I have no suggestions other than what you already have