5

We have this Magento 2.1 project running Production mode with "Update on save" mode for all indexes

Our customer manages catalog himself, and reported us some stock issues. Problem was changing quantity for a new product was not working. Process apparently ends fine, regarding the admin message ("Product was saved ok") but stock was not changed. We look in Magento log files, but we don't see any related report there

Our solution, finally, was to change indexes to "Update by schedule" and then force a reindex by console command. This solution, as far as I understand, means there is something wrong with that partial reindex fired when saving a product with "Update on save" index mode. What I am asking is for a confirmation about this... should not this problem be reported in Magento log files?

Assuming there is something wrong with our catalog data, I'd like to trace the problem, so I'd like to know which processes (the complete code trace) are fired after a product save in admin, with "Update on save" index mode. In this case, I suppose catalog_inventory ones are the most relevant

Apart from that, and checking the catalog, we've noticed some configurable products were sharing simple products, which is rare & we are not sure if could be the origin of the problem (although we assume system wouldn't let to do that if that's not allowed). Maybe this could have registered some wrong data in catalog database tables, and causing the problems with partial reindex? If that's the case... Where can I find in database which data is pending to be processed in the next full reindex process?

UPDATE

Finally, it was not an index related issue, but a cache issue https://github.com/magento/magento2/issues/7876

I am going to update question title, to clarify that for future user requests for this bug. About the bounty, I'll give the points for the most complete answer regarding the original question

  • Do your client is inserting products from the backend or they are using multiple product import?Because when I tried to insert/change product quantity from backend it get saved perfectly with no issue I am also having inderxer mode "update on save" – Abhishek Tripathi Feb 15 '18 at 13:19
  • He's using backend manually – Raul Sanchez Feb 15 '18 at 14:14
0
+200

I was working on an issue pretty similar to this one, but was related to Catalog Rule Product Index.

Due to performance issues, some indexers does not work on mode "Update or Save" and seems that this option will be removed from the template.

You can check this at https://github.com/magento/magento2/pull/11580

EDIT

I have digged a little deeper just to make sure.

When you edit a product, the stock information is updated via reindex. you can check here at the source code

The $this->getMainTable() returns cataloginventory_stock_item

The table cataloginventory_stock_status_replica is only updated when you execute the full reindex.

check the source here

$this->activeTableSwitcher->getAdditionalTableName($indexer->getMainTable())

returns cataloginventory_stock_status_replica

Then the table is updated.

Hope this helps.

  • 2
    Thanks for the answer, but I don't think changing qty for one product could be comparable to saving a catalogrule – Raul Sanchez Feb 13 '18 at 8:19
  • 2
    My point is: This could be the cause. The same way that the Catalog Rule Reindex does not work on "Update on save" mode. – Thiago Lima Feb 13 '18 at 11:24
  • Yes, I understand that & thank you for sharing it – Raul Sanchez Feb 13 '18 at 11:44
  • I found what was the problem github.com/magento/magento2/issues/7876 – Raul Sanchez Feb 16 '18 at 7:17
1

When your indexer mode set to update on save it does not fire any events related to incremental indexing.

When you have indexer mode set to schedule you should have Magento cron job configured properly it to work.

During full reindex, it fetches all the data from eav tables.

During incremental reindex, it fetches updated entity ids from relevant _cl tables.

Cross check _cl table version ids with mview_state table.

There was an issue in M2 where it does not update parent product when you save child products.

1

In Magento Product & its contents are managed with the reference of product_id but when it comes to the stock management part Magento considers item_id for the stock management of products. It is also seen many of the times that Magento skips item_id while saving the product stock information for better explanation

Let us say we are having products with product_id = 1,2,3 are having item_id = 1,2,3 respectively but it can be possible that product with product_id = 4 is having item_id = 5/6/7 or any other digit depends that how many digits is been skipped by Magento.

Now If we talk about Magentos indexing stuff, when we do Indexing in Magento, it simply transfers all the data present in one table lets take (catalog_category_product) to the other table (catalog_category_product_index).

Because Magento is considering & managing to show only those data on the storefront which is present into their respective tables with _index as a suffix into there name & as @Mr.Thiago said that Magento performs indexing for the stock after the indexing of the products this is the reason that product is get saved with half indexing & stock part is get remained as it was didn't got changed due to the half/partial indexing of the product. Or the other possible thing can be that also the difference between the item_id & product_id.

As I am yet new to Magento I am sharing my experience over here what I have seen till now in Magento development.

  • I found what was the problem github.com/magento/magento2/issues/7876 – Raul Sanchez Feb 16 '18 at 7:17
  • So by enabling the eav cache we don't need to reindex our product for the quantity updates if our indexing mode is set on update on save & we are entering product from the backend right? – Abhishek Tripathi Feb 16 '18 at 8:41
  • With "EAV" cache disabled (not enabled) & "update on save" index it should work – Raul Sanchez Feb 16 '18 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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