magento / architecture

A place where Magento architectural discussions happen
275 stars 155 forks source link

Add query to get available stores #390

Closed danielrenaud closed 4 years ago

danielrenaud commented 4 years ago

Problem

No way to get available stores. This is needed for something like a store switcher. See issue: https://github.com/magento/magento2/issues/28569

Solution

Introduce new query for fetching available stores. Based on the current store, it will return a list of StoreConfigs for other stores available under the same website.

Alternate solution: In the linked issue it is suggested to return a new field "stores" under current storeConfig, with list of available stores. To me this seems a little confusing because the available stores is not part of the current store's configuration. However I mention that approach in case it is preferred.

Requested Reviewers

@paliarush @DrewML

DrewML commented 4 years ago

In the linked issue it is suggested to return a new field "stores" under current storeConfig, with list of available stores. To me this seems a little confusing because the available stores is not part of the current store's configuration

Agree with you on this one - I don't think it makes much sense for storeConfig to have the list of store views - would make more sense if it was websiteConfig, but the UI doesn't need to know about websites to the best of my knowledge.

DrewML commented 4 years ago

Had one question re: naming, but from a technical perspective this looks good to me 👍

paliarush commented 4 years ago

We need to make sure that the list of websites is not exposed by default. Currently some merchants want to hide the fact that they are managing multiple websites, and it is controlled using setting in the admin panel. @danielrenaud I am curious where this request is coming from? As far as I remember long time ago we discussed that storefront app will have the list of known store views hardcoded because the theme is hardcoded there and not configured in the Magento admin.

danielrenaud commented 4 years ago

@paliarush This query will only expose other store views, under the same website as the current store (by Store code passed in header). So the list of websites would not be exposed. This request is to allow for creating a store switcher.

DrewML commented 4 years ago

@paliarush any more changes you want to see here?