Magento 2: "The stock item was unable to be saved. Please try again." (Error) Print

  • M2
  • 0

Issue:

Unable to save a product in the backend of Magento, with the following error message displayed, and logged in exception.log and system.log:

The stock item was unable to be saved. Please try again.

This could be an indexing issue, or a database permission issue. This is common when performing a migration or importing a database from another source.

Possible Solution(s)

1) Perform a reindex:

php bin/magento indexer:reindex

2) If indexing didn't fix the issue, create a dump of the database and check that there is no definer set:

mysqldump --single-transaction -u example -p example_magento --triggers > example_magento.sql
grep -i DEFINER example_db.sql

If it has a definer set, the following would be seen (example): 

15544:/*!50013 DEFINER=`some_other_example_user`@`localhost` SQL SECURITY DEFINER */

You could then either replace the incorrect user or just remove the definer altogether, as in the example below:

cat example_db.sql | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > example_db_without_definer.sql

Or just create a new dump of the database, removing inline using sed:

mysqldump --single-transaction -u example -p example_magento --triggers | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > example_db_without_definer.sql

Then reimport the database:

mysql -u example -p example_db < example_db_without_definer.sql

 

If you are a Create Hosting customer utilising our MageVPS Plan, feel free to submit a support ticket and we can investigate and take care of this issue for you.


Was this answer helpful?

« Back