addProduct.before + productstock + jsonapi
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!
addProduct.before + productstock + jsonapi
Hello,
I've another question... I encounteer strange things with the ProductStock Plugin + jsonapi... sorry i'm a bit confused.
When a product is out of stock I chose to check the stock before adding the product to the basket with the addproduct.before register event. My idea about it was that the out of stock product would never reach the basket and would be stopped before.
But in fact, even if the register event used is addProduct.before.
- Sometimes the error is loaded in a 404 response but the product sometimes seems to be stuck somewhere, because if I try to add another product to the basket, I still receive the same 404 error for the previous product.
- Sometimes the basket without the product out of stock is back in a 200 response but with no error or warning
In this case, I can go on and add another product but I've no message about what happened.
Would it be possible to get this 200 response but use the error field anyway in the JSON response? So I could just check it to see if the product is oos.
Thank you very much !
sbn
I've another question... I encounteer strange things with the ProductStock Plugin + jsonapi... sorry i'm a bit confused.
When a product is out of stock I chose to check the stock before adding the product to the basket with the addproduct.before register event. My idea about it was that the out of stock product would never reach the basket and would be stopped before.
But in fact, even if the register event used is addProduct.before.
- Sometimes the error is loaded in a 404 response but the product sometimes seems to be stuck somewhere, because if I try to add another product to the basket, I still receive the same 404 error for the previous product.
- Sometimes the basket without the product out of stock is back in a 200 response but with no error or warning
In this case, I can go on and add another product but I've no message about what happened.
Would it be possible to get this 200 response but use the error field anyway in the JSON response? So I could just check it to see if the product is oos.
Thank you very much !
sbn
Re: addProduct.before + productstock + jsonapi
The expected behaviour would be:
- Product is out of stock
- This product is added to the basket via JSON API
- The ProductStock basket plugin throws an exception
- A 404 including the error JSON is returned by the JSON API
It's a bit difficult to say what's wrong because your setup is unknown.
- Product is out of stock
- This product is added to the basket via JSON API
- The ProductStock basket plugin throws an exception
- A 404 including the error JSON is returned by the JSON API
It's a bit difficult to say what's wrong because your setup is unknown.
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: addProduct.before + productstock + jsonapi
Hello,
Thank you very much for trying to help me... regarding my vague question ! (sorry)
I'll try to test my case and I'm going to be more accurate in my questions
sbn
Thank you very much for trying to help me... regarding my vague question ! (sorry)
I'll try to test my case and I'm going to be more accurate in my questions
sbn
Re: addProduct.before + productstock + jsonapi
Ok ! I made some test... with only 2 products... I can give you more information
When I post a product #1 that is out of stock with json api in the basket.
Everything works fine with the product stock plugin that sends the error and delete the product from the
"\Aimeos\MShop\Order\Item\Base\Iface $order"
If I log ($order->getProducts()) at the end of the process, it is an empty array.
BUT When I post another product #2 in the same basket after I received the 404 error and I log $order->getProducts() in the plugin. Curiously, product #1 is back in the order (i'm 100% sure my post parameters for product #1 and product #2 are not the same) and product #2 is not in the order.
So another out of stock error is thrown and I'm stuck. It's confusing because it makes think that product #2 is also out of stock and it is not.
It makes me think to a cache problem?
My only solution to make an order with JSON API is to DELETE the basket and start again avoiding products out of stock. This way, the products are added normally and I can successfully store an order in the db.
When I post a product #1 that is out of stock with json api in the basket.
Everything works fine with the product stock plugin that sends the error and delete the product from the
"\Aimeos\MShop\Order\Item\Base\Iface $order"
If I log ($order->getProducts()) at the end of the process, it is an empty array.
BUT When I post another product #2 in the same basket after I received the 404 error and I log $order->getProducts() in the plugin. Curiously, product #1 is back in the order (i'm 100% sure my post parameters for product #1 and product #2 are not the same) and product #2 is not in the order.
So another out of stock error is thrown and I'm stuck. It's confusing because it makes think that product #2 is also out of stock and it is not.
It makes me think to a cache problem?
My only solution to make an order with JSON API is to DELETE the basket and start again avoiding products out of stock. This way, the products are added normally and I can successfully store an order in the db.
Re: addProduct.before + productstock + jsonapi
I found the issue, i was not an aimeos problem.
Sorry and thank you for your support.
sbn
Sorry and thank you for your support.
sbn