aem-core-cif-components icon indicating copy to clipboard operation
aem-core-cif-components copied to clipboard

StoreCode from Cookies

Open aleksitto-gh opened this issue 2 years ago • 3 comments

User Story

As a user, I want to see products in the preferrable currency

Description & Motivation

Users shall be able to switch currency for the same page path. So that can give a correct overview of products in a preferable way.

Deliverables

MagentoGraphqlClientImpl class shall be extended to support special cookie param for determining store code.

Inside the initModel method check if the cookie param is there. If it is valid then use it otherwise go with the default steps (getCustomHttpHeaders or readFallBackConfiguration).

It shall be configurable in order to make it flexible and secure. MagentoGraphqlClientImpl configuration shall have the following parameters:

  • Allow store code definition via cookies (checkbox)
  • Store code cookie param name (default value "store")
  • Allowed store codes (an array of allowed store codes)

Acceptance Criteria

Store code can be changed via cookie parameter if it is defined in the MagentoGraphqlClientImpl configuration if it is enabled and defined in the list of allowed store codes.

aleksitto-gh avatar Mar 01 '22 16:03 aleksitto-gh

This functionality is already possible today without cookie. The store code for GraphQL class is send via HTTP header, see https://devdocs.magento.com/guides/v2.4/graphql/send-request.html.

To use multiple stores with Magento and also allow users switching between them the typical AEM approach us to setup MSM site structures in AEM. See docs for details.

mhaack avatar Mar 15 '22 16:03 mhaack

Hey!

We can not use the MSM approach exactly for this case because links for such pages are used around the world.

It's true that the StoreCode param is sent via header but MagentoGraphqlClientImpl returns an immutable map and the original list of params can not be changed. It can not be changed even via java reflection (probably because the class loader from our bundle is different).

aleksitto-gh avatar Mar 18 '22 09:03 aleksitto-gh

Hey guys, any updates?

aleksitto-gh avatar Mar 28 '22 15:03 aleksitto-gh