22

I installed magento 2.4.0 on my Linux server from godaddy. I'm unable to add the products to it. It is showing the Error is The stock item was unable to be saved. Please try again. Can any one help me from this pleaseenter image description here

2

11 Answers 11

42

Please change all indexer as Update by Schedule mode in system-> index management. It's working for me.

3
  • Thank you brother, You are my heroo Commented Nov 4, 2020 at 9:20
  • Hi, I had already set to schedule, but it kept giving me the error. I changed on save and the error disappeared, but I also changed the database user permissions from "usage" to "ALL" and changed two products without getting the error.
    – Joso
    Commented May 5, 2021 at 12:15
  • This was great resonse
    – iranimij
    Commented Oct 2, 2023 at 11:15
21

If you are using Elasticsearch instead of Mysql. then please check once that elasticsearch is working or not.

sudo service elasticsearch status    // for checking the Running Status
sudo service elasticsearch start    // for Start
sudo service elasticsearch restart    // for Restart
1
  • 1
    yes, elastic search has to be up and running
    – LucScu
    Commented Aug 12, 2022 at 15:05
6

I have fixed it. There was an entry missing in cataloginventory_stock

try to run this query

INSERT INTO cataloginventory_stock (stock_id, website_id, stock_name) VALUES ('1', '1', 'default');
0
2

Go to Magento 2.4.2 installation location:

cd /var/www/html

Flush cache

sudo php bin/magento cache:flush

Chek Indexer Status

php bin/magento indexer:status

Reset Indexer

php bin/magento indexer:reset

Reindex Indexer

php bin/magento indexer:reindex

Chek Indexer Status

php bin/magento indexer:status

Chek indexer Info

php bin/magento indexer:info

Finally Flush Cache

php bin/magento cache:flush

Restart sudo reboot


Login to admin and check

2

Make sure you have Elastic search service active status ?

service elasticsearch status
1

I had the same issue, I just had to execute:

php bin/magento indexer:reindex
1

For me, the solution was to use Opensearch instead of Elasticsearch. There is an option in the backend for that, by default elastic is selected.

Go to Magento Admin then,

Stores > Configurations > Catalog > Catalog > Catalog Search

Admin search engine backend

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 18, 2023 at 14:15
1

Tested in Magento ver. 2.4.5-p1. Please make sure Elastic Search is running using the command

sudo service elasticsearch status

If it is not running start elastic search using command

sudo service elasticsearch start
0

I've Migrated the magento 2.3.x into 2.4.x. I faced the same issues. I've resolved this issue the following way.

  1. INSERT INTO cataloginventory_stock (stock_id, website_id, stock_name) VALUES ('1', '1', 'default');

  2. php bin/magento indexer:reindex

  3. php bin/magento cache:flush

But still i am facing the same issue, then I did the below steps.

  1. mysqldump --single-transaction -u root -p mydb --triggers | sed -e 's/DEFINER[ ]=[ ][^]*/*/' > mydb_without_definer.sql
  2. DROP DATABASE mydb;
  3. create DATABASE mydb;
  4. mysql -u root -p mydb < mydb_without_definer.sql
  5. php bin/magento indexer:reindex
  6. php bin/magento cache:flush

Thank you! Pilathraj

0

On Magento 2.4.6, which now uses OpenSearch instead of Elastisearch

I was having this problem until I added the following to the end of
/etc/opensearch/opensearch.yml

plugins.security.disabled: true

Remember to restart OpenSearch after the edit. On my system this was
systemctl restart opensearch

I am running both Magento2 and OpenSearch on a single server. OpenSearch is listening on localhost:9200; which I can secure through IPTABLES. I suspect that configuring OpenSearch's TLS settings correctly would also work.

0

If you are not using elastic search and you are using opensearch

Please configure opensearch from

Store > Configuration > Catalog > Catalog > Catalog Search > Search Engine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.