JSON API - search catalog
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
JSON API - search catalog
AIMEOS Laravel 2020.10.*
Thank you for all your great supports,
1) . Currently I am trying to get the catalog list from JSON API, by following this https://aimeos.org/docs/latest/frontend ... categories
This is great if I am using for only 1 level
In my case, I need to get more level of the catalog, the problem is: there will be too many JSON API
if I have:
level 1: 8catalogs
level2: 3 catalogs
that will be 24 JSON API call
there will be greater way to get around this
2) . I am trying to call this API on the Laravel demo
As you will see the result of the response will be all the catalog level with the specified level,
The problem is it does not include the child catalog in the response but only the text.
------------------------------------------------------------------------------------------
I am checking the source code of Json API and found the reason here:
- The catalog relationships are manage by the catalog table rather than catalog.list so the line 66 wont execute
- The line 59:
if you call the API with the First way (follow the docs) it is execute.
if you use the second way, (search catalog with level: 0 , include:text, catalog) this will not execute.
Please help me check it, and give me the way to get the Include Child catalogs from the search without using catalog.lists manage relationship
Thank you for all your great supports,
1) . Currently I am trying to get the catalog list from JSON API, by following this https://aimeos.org/docs/latest/frontend ... categories
This is great if I am using for only 1 level
In my case, I need to get more level of the catalog, the problem is: there will be too many JSON API
if I have:
level 1: 8catalogs
level2: 3 catalogs
that will be 24 JSON API call
there will be greater way to get around this
2) . I am trying to call this API on the Laravel demo
Code: Select all
var url = `https://laravel.demo.aimeos.org/default/jsonapi`; // Base URL from config
var promise = $.ajax( url, {
method: "OPTIONS",
dataType: "json"
});
promise.done( function( options ) {
var args = {};
var params = {
'include': 'text,catalog',
'filter': {
'&&': [
{'==': {'catalog.level': 0}
}
]
}
};
console.log(options)
console.log('end points')
console.log(options.meta.resources)
var result = $.ajax({
method: "GET",
dataType: "json",
url: `${options.meta.resources['catalog']}`,
data: params
});
result.done( function( result ) {
console.log('resource data')
console.log( result.data );
});
});
The problem is it does not include the child catalog in the response but only the text.
------------------------------------------------------------------------------------------
I am checking the source code of Json API and found the reason here:
Code: Select all
ext/ai-client-jsonapi/client/jsonapi/templates/catalog/standard.php
- The line 59:
if you call the API with the First way (follow the docs) it is execute.
if you use the second way, (search catalog with level: 0 , include:text, catalog) this will not execute.
Please help me check it, and give me the way to get the Include Child catalogs from the search without using catalog.lists manage relationship
Re: JSON API - search catalog
If you restrict the categories to level "0" in your filter, only the root node will be returned. Instead, use this to get the root node and all categories one level below:
The sub-categories data in the "included" section contains links to retrieve the sub-category and their sub-sub-categories if you use "'include': 'catalog'" again. You only need to fetch the sub-sub-categories on user request, so you need 1-2 requests max. in all cases.
Code: Select all
var url = `https://laravel.demo.aimeos.org/default/jsonapi`; // Base URL from config
$.ajax( url, {
method: "OPTIONS",
dataType: "json"
}).done( function( options ) {
$.ajax({
method: "GET",
dataType: "json",
url: `${options.meta.resources['catalog']}`,
data: {'include': 'text,catalog'}
}).done( function( result ) {
console.log( result.data );
});
});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: JSON API - search catalog
The problem in my case is:
I need to pre-fetch all the catalogs in the sub-sub-categrory
example:
level: 0 : 1 catalog
level: 1 : "N" catalog
level: 2: 4 catalog each
------------------------------------
If i call as you I will need to call "N" requests to get all the level 2
I need to pre-fetch all the catalogs in the sub-sub-categrory
example:
level: 0 : 1 catalog
level: 1 : "N" catalog
level: 2: 4 catalog each
------------------------------------
If i call as you I will need to call "N" requests to get all the level 2
Re: JSON API - search catalog
There may be cases where this a valid requirement provided you have a low number categories (like in your case). We've added a new configuration in the dev-master branch to allow fetching the complete catalog tree now:
https://github.com/aimeos/ai-client-jso ... 0b0dbafc6b
https://github.com/aimeos/ai-client-jso ... 0b0dbafc6b
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: JSON API - search catalog
I tried this but it did not work,
How do you config it?
Will this enable when I use filter search catalog, the JSON api will also return the children of found catalogs?
How do you config it?
Will this enable when I use filter search catalog, the JSON api will also return the children of found catalogs?
Re: JSON API - search catalog
Remember, it's only in dev-master branch of the aimeos/ai-client-jsonapi package. You are likely using a ~2020.10 version.
Yes, the whole tree will be returned if you enable this option and use "include=catalog" in your request.
Yes, the whole tree will be returned if you enable this option and use "include=catalog" in your request.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: JSON API - search catalog
yes that's worked,
thank you so much for your help
thank you so much for your help