integer-net / Solr

Solr Module for Magento 1.
http://de.integernet-solr.com/
6 stars 0 forks source link

Store emulation is not restored correctly #13

Closed phizab closed 8 years ago

phizab commented 8 years ago

If I save a product in admin area and the product is in two stores especially with different languages, I've got problems with the store emulation. There is a call to start emulation for each store, but there is only one restoring. So the following happens:

  1. I'm in admin store
  2. Emulating german store for loading product data
  3. Emulating english store for loading product data
  4. Stopping emulation and setting it to german store, because the initial environment in step 3 is the german store.
  5. The admin area is now in a wrong state and I have to login again.

This problem should be fixed with line 421. But the translation is also not restored correctly. So I switched the position of the locale setting in method _emulateStore, because otherwise when starting the emulation, a wrong initial locale would be set.

Can you please check this?

schmengler commented 8 years ago

I could not reproduce the bug in Magento 1.9.2.3 with sample data, "Use HTML from Solr Index" = "Yes" and products with different description per store view. I could save the product and reindex from admin without errors. Can you share your module configuration and Magento version?

Your PR seems to make sense, but we need to test it somehow.

phizab commented 8 years ago

I think it has nothing to do with configuration, because method _addResultHtmlToProductData is called every time a product gets reindexed independent on any setting. It is difficult to see the problem, but there may be some hints.

I saw the problem in my local installation by the following (product is in one website with two stores, locale de_DE and en_US, Magento 1.9.2.3):

  1. I have installed the german locale package and use german language in backend. After saving the product I see the message "The product has been saved.", but it should be "Der Artikel wurde gespeichert.". This is because locale is not restored correctly.
  2. I use different secure urls for admin and frontend. In admin I have http:// and in frontend I configured https:// for secure urls. After saving the product I get redirected to https:// url, so the frontend url is used. Then it looks like the following screenshot and I have to relogin. And I have to do every time I save a product. solr_product_save

Sadly the easiest way to see the problem is to debug method _emulateStore, when saving a product with two different stores. You will see in line 748 of IntegerNet_Solr_Model_Indexer_Product how _initialEnvironmentInfo gets rewritten wrong when reaching this method the second time.

So the problem may be invisible for users in admin area, but exists in code and can produce errors like in my installation. I don't know if the solr index is affected of it. I hope this helps you a bit and that you can reproduce the problem.