Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to fetch products by brand #465

Closed
hmvmpire opened this issue Oct 5, 2023 · 2 comments
Closed

how to fetch products by brand #465

hmvmpire opened this issue Oct 5, 2023 · 2 comments

Comments

@hmvmpire
Copy link

hmvmpire commented Oct 5, 2023

can you please specify how to fetch products by brands in headless sdk

@rallu
Copy link
Contributor

rallu commented Oct 5, 2023

For that you need to make custom query.

API documentation here: https://docs.klevu.com/apis/smart-search-examples#8x7Uc

In SDK you can any API request with raw() function.

So the example in link above would be in SDK code:

await KlevuFetch(
  raw({
    id: "search",
    settings: {
       customANDQuery: "(size:\"Small\" OR size:\"Medium\") AND -(brand:\"KKE\")",
       fields: ["id","name","size","brand"],
       limit: 10
    }
  })
)

@rallu
Copy link
Contributor

rallu commented Oct 6, 2023

I was informed that customANDQuery is being deprecated and we should use our new updated advanced filtering.

For that we have handy modifier for you to use:

await KlevuFetch(
  search(
    "*", 
    { limit: 10 }, 
    advancedFiltering([
      {
        key: "brand",
        valueOperator: "INCLUDE",
        singleSelect: false,
        values: ["MNH"]
      }
    ])
  ) 
)

@rallu rallu closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants