You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An error code 400 is returned with the message: The product was unable to be saved. Please try again.
After some debugging, I found out what was happening. As the error message is not very clear about the problem itself, and there was no other information about the error being logged to the log files. I found where the exception was being thrown and just added the actual error message to the exception:
With that change the error message now returns: The product was unable to be saved. Please try again.Registry key \"movement_section\" already exists
The error occurs on vendor/elgentos/magento2-inventory-log/Plugin/Webapi/Stock/StockItemRepository.php at line 20. If I comment out the register->register() method. The product stock is updated successfully, but it means that the registration of the movement_section key has already been set before the beforeSave() method was called. We can see on the screenshot below, that the the last two records have the message indicating that this stock update was made manually, but it was made through the rest API.
After a little more digging, I found out that the registration of the movement_section key is happening at /vendor/elgentos/magento2-inventory-log/Observer/SaveInventoryDataObserver.php. Configured under etc/events.xml:
Error updating product stock through rest API
Preconditions
Steps to reproduce
Try to update a product stock from the rest API.
Request example:
PUT: /rest/all/V1/products/24-MB01
Body:
Expected result
Actual result
After some debugging, I found out what was happening. As the error message is not very clear about the problem itself, and there was no other information about the error being logged to the log files. I found where the exception was being thrown and just added the actual error message to the exception:
With that change the error message now returns: The product was unable to be saved. Please try again.
Registry key \"movement_section\" already exists
The error occurs on
vendor/elgentos/magento2-inventory-log/Plugin/Webapi/Stock/StockItemRepository.php
at line 20. If I comment out the register->register() method. The product stock is updated successfully, but it means that the registration of themovement_section
key has already been set before the beforeSave() method was called. We can see on the screenshot below, that the the last two records have the message indicating that this stock update was made manually, but it was made through the rest API.After a little more digging, I found out that the registration of the
movement_section
key is happening at/vendor/elgentos/magento2-inventory-log/Observer/SaveInventoryDataObserver.php
. Configured under etc/events.xml:The text was updated successfully, but these errors were encountered: