Page 1 of 1

Attribute search

Posted: 15 Mar 2018, 10:08
by Anshul Dua
Hi Team, Here i wan to filter the product according to the attributes using JSON API. Can i list the attribute using attribute type? in

Re: Attribute search

Posted: 15 Mar 2018, 21:08
by aimeos
Yes, sure. Use a filter for "attribute.type.code":

Code: Select all

var params = {];

if( servicedesc.meta.prefix ) {
    params[servicedesc.meta.prefix] = {filter: {'==': {'attribute.type.code': 'mytype'}}};
} else {
    params = {filter: {'==': {'attribute.type.code': 'mytype'}}};
}
 
$.ajax({
    method: "GET",
    dataType: "json",
    url: servicedesc.meta.resources['attribute'], // returned from OPTIONS call
    data: params
}).done( function( result ) {
    console.log( result.data );
});
It's documented there:
Filtering: https://aimeos.org/docs/Developers/Clie ... the_result
Parameter nesting: https://aimeos.org/docs/Developers/Clie ... parameters

Re: Attribute search

Posted: 16 Mar 2018, 06:13
by Anshul Dua
I am using the JSONAPI. Where can i add this code?

Re: Attribute search

Posted: 16 Mar 2018, 09:01
by aimeos
In your client application that calls the JSON REST API server endpoints

Re: Attribute search

Posted: 16 Mar 2018, 17:07
by Anshul Dua
My issues are resolved. One more thing
Can i get the attribute list according to the attribute type. Because this will easier to filter the data and compare the attribute lable with my value.?
Currently I am using this API to list the attributes
http://localhost/jsonapi/attribute