Initial work, copied from the Shopify provider

This commit is contained in:
Patryk Zawadzki
2021-04-14 14:09:40 +02:00
committed by Zaiste
parent 685fb932db
commit ffe5a1c20e
79 changed files with 16981 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
import getSortVariables from './get-sort-variables'
import type { SearchProductsInput } from '../product/use-search'
export const getSearchVariables = ({
brandId,
search,
categoryId,
sort,
}: SearchProductsInput) => {
let query = ''
if (search) {
query += `product_type:${search} OR title:${search} OR tag:${search}`
}
if (brandId) {
query += `${search ? ' AND ' : ''}vendor:${brandId}`
}
return {
categoryId,
query,
...getSortVariables(sort, !!categoryId),
}
}
export default getSearchVariables