What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

We have some trouble with the stores setup in our environment. The setup is quite equal to the b2b D

UU07J5ZGC
UU07J5ZGC Posts: 11 πŸ§‘πŸ»β€πŸš€ - Cadet
edited August 2020 in Help

We have some trouble with the stores setup in our environment. The setup is quite equal to the b2b Demo Shop: 2 stores sharing one database (like DE and AT in the demo shop), a third store with a separate Database (like US in the demo shop). One main difference is, that the locales differ between the 2 stores using the first DB and the third store using the second DB:
Store 1:
β€’ DB 1
β€’ Locale: de_DE
Store 2:
β€’ DB 1
β€’ Locale: de_DE
Store 3:
β€’ DB 2
β€’ Locales: de_CH, fr_CH, it_CH
We stumbled upon the following problems:

Stores in Zed-Backend:
During setup (docker sdk), all 3 stores from stores.php are written in both DBs into spy_store. Therefore, in Zed-Backend for Store 1/Store 2 I can also assign e.g. products to Store 3 and vice versa. This is highly miss leading, as Store 3 has no connection the DB used by Store 1/Store 2

Missing locales during P&S:
When publishing ProductAbstract, errors occur in \Spryker\Zed\ProductPageSearch\Business\Publisher\ProductAbstractPagePublisher::hydrateProductAbstractLocalizedEntitiesWithProductCategories because $productAbstractLocalizedEntities is empty. $productAbstractLocalizedEntities is build in \Spryker\Zed\ProductPageSearch\Business\Publisher\ProductAbstractPagePublisher::findProductAbstractLocalizedEntities, where all stores (from stores.php) are iterated and entities matching the iterated store's locales are searched. As the locales between Store 1/Store 2 and Store 3 are different, no products with locale de_DE are present in the DB of Store 3 and no products with locale de_CH, fr_CH or it_CH are present in the DB of Store 1/Store 2.

As all three stores share the same codebase (and therefore the stores.php), is there a possibility to fix/work around the depicted problems?

Many thanks for your help.

Comments

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 πŸ§‘πŸ»β€πŸš€ - Cadet

    I think the 2nd issue is a result of the 1st one. @ULYHPR789 could you please reveal if we’ve had a similar issue on one of our recent projects and if yes - what was the solution there?

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    It is all about data import and stores.php.

    1. Data import is easiest one: you can always run different data imports processes for different databases. We have this in the next demoshops release, as example, docker.yml:
        demodata:
            import-demodata:
                command: "vendor/bin/console data:import --config=data/import/local/full_${SPRYKER_REGION}.yml"
    

    Latest Docker SDK provides SPRYKER_REGION env variable base on deploy.yml.

    stores.php - that’s tricky part. We have a huge feature in backlog that makes stores dynamic, however it is far from be done. As a workaround we propose to have logic on stores.php (it is a part of the next demoshops release too):

    $stores = [];
    
    if (!empty(getenv('SPRYKER_ACTIVE_STORES'))) {
        $activeStores = array_map('trim', explode(',', getenv('SPRYKER_ACTIVE_STORES')));
    ....
    

    Latest Docker SDK provides SPRYKER_ACTIVE_STORES env variable base on current region and deploy.yml.

  • UU07J5ZGC
    UU07J5ZGC Posts: 11 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thanks for your reply and the suggestions to work around the problems, but I've still got some questions.

    Regarding topic 1: when I look at \Pyz\Zed\DataImport\Business\DataImportBusinessFactory::createStoreImporter in current shop suite, import data is revealed (in the end) from stores.php. So how would a region specific import.yml help here?

    Regarding topic 2: I'm on Version 1.18.3 (origin/master) of spryker/docker-sdk but can't find SPRYKER_ACTIVE_STORES in the code or the output of export in CLI container. Is the version you mentioned already released?

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 πŸ§‘πŸ»β€πŸš€ - Cadet
    1. Stores.php will take only active stores based on SPRYKER_ACTIVE_STORES.
    2. Sorry, I miss-led you. I have that implemented in my head only. πŸ™‚
      So there are 2 options:

    A. different deploy.ymls per database.

    Have this in deploy.yml.

    image:
      tag: spryker/php:7.3-alpine3.12
      environment:
        SPRYKER_DEFAULT_STORE: "DE"
        SPRYKER_ACTIVE_STORES: "DE,AT"
    

    config/Shared/default_store.php

    return getenv('SPRYKER_DEFAULT_STORE') ?: 'DE';
    

    config/Shared/stores.php

    $stores = [];
    
    if (!empty(getenv('SPRYKER_ACTIVE_STORES'))) {
        $activeStores = array_map('trim', explode(',', getenv('SPRYKER_ACTIVE_STORES')));
    ....
    

    B. Based on SPRYKER_REGION
    config/Shared/default_store.php

    return getenv('SPRYKER_REGION') === 'US' ? 'US' : 'DE';
    

    config/Shared/stores.php

    $stores = [];
    
    if (!empty(getenv('SPRYKER_REGION'))) {
        $activeStores = ['EU' => ['DE', 'AT'], 'US' => ['US']][getenv('SPRYKER_REGION')];
    ....
    
  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    As you see it is workarounds. No straight way for now. We are still considering having SPRYKER_ACTIVE_STORES in DSDK

  • UU07J5ZGC
    UU07J5ZGC Posts: 11 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thank you for clarification. I'll have a look how to transfer this to our project.