trustpilot / plugin-magento2

Magento 2 plugin for sending invitation data to Trustpilot
MIT License
10 stars 27 forks source link

Error in getWebsiteOrStoreId() method, in helper Data.php #79

Open SamueleMartini opened 3 years ago

SamueleMartini commented 3 years ago

The method getWebsiteOrStoreId() checks from the request whether the context is a store or a website, takes its ID and then returns it. However, the value returned by this method is always passed to the "setStore" method (ex. in method getFirstProduct(), row 204 in Data.php) even when the returned ID is a website Id and not a store view ID! If I have a website with an ID that does not correspond to that of a store, the "store -> configuration" section returns an exception "store was not found" In the other cases the section loads without errors, but it has loaded an incorrect store anyway, because it has loaded the store with the same ID as the website and not the website.

You can reproduce the error by creating two store views, associating them with the main website and then deleting the first store view created. In this way the website will have ID 1, but there will be no store with ID 1. Then go to module configurations and change scope to "website" to see the exception.

immagine