JSONADM API and rebuild index
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
JSONADM API and rebuild index
Hi, when a new product is associated with a category in catalog, for example, it is necessary to rebuild the index in order to view it in the frontend.
When this operation is made with JSONADM API, how is possible to rebuild the index, for example every time the new relationship is patched?
Thank you.
When this operation is made with JSONADM API, how is possible to rebuild the index, for example every time the new relationship is patched?
Thank you.
Re: JSONADM API and rebuild index
There's no way to rebuild the index using the JsonAdm API because it's a potentially long running operation that takes much longer than the request is allowed to. It's also not possible to execute the cronjob from the API.
The only possibility might be to create a job in the message queue and a corresponding job controller that rebuild the index if there's a job in the queue. But there are a few things to keep an eye on: Rebuild jobs must not be executed in parallel and what if there are a lot of jobs in the queue due to several changes? Are they all executed one by one? Is only the first executed and what if another change requires to rebuild a product whose index records already has been rebuild?
Our suggestion would be to rebuild only the index entries of the product whose reference has been added, modified or deleted like it's done for the product in the JQAdm interface:
https://github.com/aimeos/ai-admin-jqad ... #L227-L228
Can you create a PR for this change?
The only possibility might be to create a job in the message queue and a corresponding job controller that rebuild the index if there's a job in the queue. But there are a few things to keep an eye on: Rebuild jobs must not be executed in parallel and what if there are a lot of jobs in the queue due to several changes? Are they all executed one by one? Is only the first executed and what if another change requires to rebuild a product whose index records already has been rebuild?
Our suggestion would be to rebuild only the index entries of the product whose reference has been added, modified or deleted like it's done for the product in the JQAdm interface:
https://github.com/aimeos/ai-admin-jqad ... #L227-L228
Can you create a PR for this change?
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: JSONADM API and rebuild index
https://github.com/aimeos/ai-admin-jsonadm/pull/6
I tried in my extension and this code works when adding a product in a category, so it works also when any other relationships of the product is patched.
I don't know if there are other stuff to take care (other domains that needs to rebuild the index, etc).
I tried in my extension and this code works when adding a product in a category, so it works also when any other relationships of the product is patched.
I don't know if there are other stuff to take care (other domains that needs to rebuild the index, etc).
Re: JSONADM API and rebuild index
Fixed a few things in your code and extended the tests:
https://github.com/aimeos/ai-admin-json ... #L438-L445
Now, PATCH and POST will update the index but still does not DELETE.
https://github.com/aimeos/ai-admin-json ... #L438-L445
Now, PATCH and POST will update the index but still does not DELETE.
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: JSONADM API and rebuild index
In the next days I will do a PR also for DELETE method.