Data collection querying / filtering by productOption defined in Hebrew

At https://www.clothing-tale.com/ I have productOption defined in Hebrew and in Stores/Products collection it looks like:

now I am trying to query this collection with wix-data:

and totalCount always gives a zero, although I have products with this category.

If I change product option name from Hebrew to English:

then the code works just fine:

wixData.query('Stores/Products').eq('productOptions.cat.value', 'נעליים')...

But changing option name to English also changes filter section label on the store page to English, and I need it in Hebrew.

So my question is: how can I query / filter products by option defined in Hebrew? Or is it possible to define option name in Hebrew but having collection key in English, something like:

I posted this question on stackoverflow as well, but - no answers there…

thanks in advance!

Did you ever figure this out?

Nope, still waiting for professional response from WIX…

It is not exactly what I was looking for, but I succeeded to get results using wixSearch:

wixSearch.search('')
    .documentType('Stores/Products')
    .hasAll('options', ['קטגוריה', 'נעליים'])
      .find()
      .then((results) => {
 
         if (results.documents.length > 0) {
           const firstDocument = results.documents[0];
           console.log('firstDocument', firstDocument);
         } else {
           console.log("No matching results");
         }
      })
      .catch((error) => {
        console.log(error);
      });

I can use it to build fully customized dynamic pages

For now, I changed my product options’ names to English.

The situation with non-latin keys got even worse. Before last WIX store update I could refresh page with query params like: ‘…?קטגוריה=נעליים’ and the products would get filtered and category checkbox would get checked, now it does not work with Hebrew. However, if I change key to English - it works: ‘…?category=נעליים’

The following line of code is the problem:
.eq(‘productOptions.קטגוריה.value’, ‘נעליים’)
Non-Latin characters are not valid in Javascript.

This should work:
.eq(‘productOptions[‘קטגוריה’].value’, ‘נעליים’)
Instead of using קטגוריה in Javascript, use it as a key.

Thanks Yisrael for your answer. I suppose what you meant was .eq(‘productOptions['קטגוריה'].value’, ‘נעליים’) or .eq(‘productOptions[“קטגוריה”].value’, ‘נעליים’) or .eq(“productOptions[‘קטגוריה’].value”, ‘נעליים’) or
.eq(productOptions[${'קטגוריה'}].value, ‘נעליים’)

Unfortunately, none of these works. Eventually, there is a POST to find.ajax endpoint (in my tests it was to https://1fa0a02a-d9fd-43ea-9cf1-d7d28cf261f4.dev.wix-code.com/wix/data-web.jsw/find.ajax.) )..) (in PRODUCTION it will go to https://www.clothing-tale. com//_api/wix-code-public-dispatcher/siteview/wix/data-web.jsw/find.ajax,) ),,) there are 3 query params: gridAppId, instance and viewMode , this POST is issued by getJSON function:

getJSON: function(e) {
var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] :
, t = this.currentPath ? location.href.replace(this.currentPath, e) : getPathWithBaseUrl(this.baseUrl, e, this.queryParameters)
, o = this.options
, n = o.headers
, i = void 0 === n ? {} : n
, s = o.withCredentials
, a = void 0 !== s && s
, u = o.timeout
, c = void 0 === u ? THIRTY_SECONDS : u
, p = _objectSpread(_objectSpread({}, i), {}, {
“Content-Type”: “application/json”
});
return new Promise(function(e, o) {
var n = new XMLHttpRequest;
function i(e) {
var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : “”
, t = new Error(r);
return t.xhr = n,
t.errorType = e,
t
}

POST payload:

[
“Stores/Products” ,
{
“$and” : [
{
“productOptions[‘קטגוריה’].value” : “נעליים”
}
]
},
null ,
0 ,
50 ,
null ,

]

It responds with status 200 with error message: Unknown token productOptions[‘קטגוריה’].value → Map($eq → נעליים)

Here is full response:
{“result”:{“message”:“{"message":"Unknown token productOptions[‘קטגוריה’].value → Map($eq → נעליים)","details":{}}”,“name”:“Error”,“stack”:“Error: {"message":"Unknown token productOptions[‘קטגוריה’].value → Map($eq → נעליים)","details":{}}\n at errorWithCode (@wix/wix-data-errors/lib/errors.js:322:15)\n at wixDataError (@wix/wix-data-errors/lib/errors.js:282:10)\n at createError (wix/node_modules/@wix/wix-dis-client/src/utils/error-utils.js:40:10)\n at rejectWithError (wix/node_modules/@wix/wix-dis-client/src/utils/error-utils.js:29:25)\n at mapError (wix/node_modules/@wix/wix-dis-client/src/utils/error-utils.js:14:14)”,“code”:“WD_VALIDATION_ERROR”,“_elementoryError”:true},“exception”:true}

BTW, the same error I am getting when POSTING at the same manner Latin letters option name:
“Unknown token productOptions[‘Category’].value → Map($eq → נעליים)”

Please assist, thanks in advance,
Andriy

(I am posting this reply under my wife’s account, which is the owner of the Premiun WIX subscription)

@revy101 Really sorry for the delay getting back to you - I was out of the office for a week…

I really don’t understand how the following worked for you:
.eq(‘productOptions.cat.value’, ‘נעליים’)
I missed the fact that you have single quotes around the field key value which turns it into a literal. You need to get rid of the single quotes, like this:
.eq(productOptions.cat.value, ‘נעליים’)

So…

Instead of this (my mistake):
.eq( productOptions[‘קטגוריה’].value’, ‘נעליים’)

You should have this (without the single quotes around the field key):
.eq(productOptions[‘קטגוריה’].value, ‘נעליים’)

Thanks Yisrael,

regarding "I really don’t understand how the following worked for you:
.eq(‘productOptions.cat.value’, ‘נעליים’) " that you wrote, this is taken from the WIX support page - https://support.wix.com/en/article/corvid-wix-stores-products-collection-fields#product-options-productoptions and it perfectly works for the product options set in Latin letters, but unfortunately does not work when set in Hebrew for example (I guess the same problem will be for any other non Latin language ABC)

eq() (https://www.wix.com/corvid/reference/wix-data/wixdataquery/eq) function’s first argument should be a string and it is used for inner DB lookup, Within Stores/Products DB it will look for all products satisfying following criteria: having **productOptions** named " קטגוריה " to be equal " נעליים " .
I cannot use it like this:

const wdq = wixData.query('Stores/Products');
wdq.eq(productOptions['קטגוריה'].value, 'נעליים')
  .find()
  .then(aaa => {
    console.log('AAA - totalCount', aaa.totalCount);
  });

because I do not have productOptions object locally.
Also, I cannot use it like this (double quotes around the first argument):

const wdq = wixData.query('Stores/Products');
wdq.eq("productOptions['קטגוריה'].value", 'נעליים')
  .find()
  .then(aaa => {
    console.log('AAA - totalCount', aaa.totalCount);
  });

I will get “Unknown token productOptions[‘Category’].value → Map($eq → נעליים)” error returned by final HTTP post.

@revy101 Aha! I see what you mean about the form of .eq(). My mistake - I thought you were doing a lookup of a local JSON object. Now I understand that it’s a query of the Stores database.

It’s a special syntax and it does in fact require the quote marks. So, this is correct:

wdq.eq('productOptions.category.value', 'נעליים')

I intentionally used category as I suspect that the problem is with non-Latin characters in the Javascript.

Not sure why this doesn’t work:

wdq.eq("productOptions['קטגוריה'].value", 'נעליים')

Although it seems to me that it’s a problem with the non-Latin characters.

I’m missing something. I’m need to take a closer look at this.

By the way, does this work?

wdq.eq("productOptions['Category'].value", 'נעליים')