Calling Developers!
We are reenergizing our code contribution process! Learn More

Hi everyone , Can anyone please suggest me how can we create Store in Spryker b2c shop and get all s

Options
U04SA0H260N
U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
edited June 2023 in Spryker Development

Hi everyone ,
Can anyone please suggest me how can we create Store in Spryker b2c shop and get all store list available there

Comments

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options
  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options
    Store::getInstance()->getInactiveStores()
    
  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    This will return all store names except the current one.

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    the Store where it define name space for it

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Can you please ask a complete question? I'm not able to get what you are asking for

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    in this Store::getInstance()->getInactiveStores() we are using Store class function so i have to include or use that class at top of my file so i have to provide path for that so what path i have to give

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    one more doubt is it necessary to define or create a Code Bucket for creating a store

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Spryker\Shared\Kernel\Store

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Have a look at \SprykerConfig\CodeBucketConfig::getCodeBuckets this automatically assumes that all your configured stores are a valid code bucket.

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    To answer your question, no it's not necessary to define a code bucket to create a store.

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options
    1. Configure installation recipes
      Add the new stores to the installation recipes in config/install/* as follows:

    HowTo: Set up multiple stores
    Last updated: December 22, 2022
    Edit on GitHub
    Multiple stores in cloud environments
    For instructions about setting up multiple stores in Spryker Cloud Commerce OS, see Add and remove databases of stores.
    With the Spryker Commerce OS, you can create multiple stores per your business requirements for different scenarios. The multi-store setup is very versatile and customizable—for example, you can do the following:
    • Build one store for multiple countries and languages or separate stores for each region.
    • Make abstract products, discounts, and other logic and code shared between stores or create a dedicated setup for each of them.
    • Define separate search preferences to create an entirely different set of rankings, rules, and settings per store—for example, a date format or a currency.
    • Set up a default store.
    Multi-store setup infrastructure options
    Multi-store setup 1: Database, search engine, and key-value storage are shared between stores.

    Due to the resources being shared, the infrastructure costs are low. This setup is most suitable for B2C projects with low traffic and a small amount of data like products and prices.
    Multi-store setup 2: Each store has a dedicated search engine and key-value storage while the database is shared.

    This setup is most suitable for B2B projects with high traffic and a large amount of data.
    Multi-store setup 3: Each store has a dedicated database, search engine, and key-value storage.

    This setup is most suitable for projects with the following requirements:
    • Completely different business requirements per store, like business logic and features.
    • Independent maintenance and development flow.
    • Separated data management for entities like products, customers, and orders.
    • On-demand setup of any type of environment per store, like test, staging, or production.
    It’s the most expensive but flexible option in terms of per-store scaling and performance.
    Set up multiple stores
    To set up multiple stores, follow the steps in the following sections:
    Configure code buckets
    Code buckets provide an easy way to execute different business logic in runtime based on different HTTP or console command requests. To configure code buckets, see Code buckets.
    Configure stores
    1. Define the desired stores in config/Shared/stores.php. In the following example, DE and AT stores are defined:
    config/Shared/stores.php

    <?php
    
    $stores = [];
    
    $stores['DE'] = [
        'contexts' => [
            '*' => [
                'timezone' => 'Europe/Berlin',
                'dateFormat' => [
                    'short' => 'd/m/Y',
                    'medium' => 'd. M Y',
                    'rfc' => 'r',
                    'datetime' => 'Y-m-d H:i:s',
                ],
            ],
            'yves' => [],
            'zed' => [
                'dateFormat' => [
                    'short' => 'Y-m-d',
                ],
            ],
        ],
        // locales configuration
        'locales' => [
             'en' => 'en_US',
             'de' => 'de_DE',
        ],
        // country and currency configuration
        'countries' => ['DE'],
        'currencyIsoCode' => 'EUR',
        // Queue pool is the mechanism which sends messages to several queues.
        'queuePools' => [
            'synchronizationPool' => [
                'AT-connection',
                'DE-connection',
            ],
        ],
        'storesWithSharedPersistence' => ['AT'],
    ];
    
    $stores['AT'] = [
        'contexts' => [
            '*' => [
                'timezone' => 'Europe/Vienna',
                'dateFormat' => [
                    'short' => 'd/m/Y',
                    'medium' => 'd. M Y',
                    'rfc' => 'r',
                    'datetime' => 'Y-m-d H:i:s',
                ],
            ],
            'yves' => [],
            'zed' => [
                'dateFormat' => [
                    'short' => 'Y-m-d',
                ],
            ],
        ],
        'locales' => [
             'en' => 'en_US',
             'de' => 'de_AT',
        ],
        'countries' => ['AT'],
        'currencyIsoCode' => 'EUR',
    ];
    
    return $stores;
    
    1. Optional: Define store-specific configuration:
    2. For one or more stores you’ve defined in config/Shared/stores.php, define a separate store-specific configuration. For example, config/Shared/config-default_docker_de.php is the configuration file for the DE store in the docker environment.
    3. To apply the defined store-specific configuration, adjust the related deploy file in the environment section.
      In the following example, the docker_de environment name points to the config/Shared/config-default_docker_de.php store-specific configuration file. For more information about this deploy file parameter, see environment:
    ....
    
    environment: docker_de
    
    image:
      tag:
    
    1. Define the default store in config/Shared/default_store.php. In the following example, we define DE as the default store.
    <?php
    
    return 'DE';
    ...
    
    1. To import data for the stores you’ve added, adjust all the import files and import configuration.
      For example, define the import source for the DE store you’ve added:
    #2. Catalog Setup data import
    ...
    - data_entity: product-price
      source: data/import/common/DE/product_price.csv
    ...   
    
    1. Configure installation recipes
      Add the new stores to the installation recipes in config/install/* as follows:
    ...
    
    stores:
        ...
        - {STORE_NAME}
    ...    
    

    For example, to add the AT and DE stores, adjust an installation recipe as follows:

    ...
    
    stores:
        ...
        - DE
        - AT
    ...    
    

    Where is that install recipe file i am not getting what should i do

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    i am just asking about this
    1. Configure installation recipes
    Add the new stores to the installation recipes in config/install/* as follows:

    ...
    
    stores:
        ...
        - {STORE_NAME}
    ...    
    

    For example, to add the AT and DE stores, adjust an installation recipe as follows:

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Look into your directory config/install this contains several yml files.
    To be able to run the install commands for all your stores you need to adapt for which stores those commands should run, by adding your store to the key stores

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    i gone through all the process but the store is not sowing in backend

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Is it added to spy_stores in the DB?

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    Have you set SPRYKER_ACTIVE_STORES to DE,<Your Store>

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    no

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    what it not added to DB

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    (in https://github.com/spryker-shop/b2b-demo-shop/blob/master/deploy.dev.yml#L13)

    Afterwards you need to rebuild your local containers:

    docker/sdk boot -s deploy.dev.yml
    docker/sdk up --build
    
  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    what it not added to DB

    There is no automatism to create the DB entry, you need to do this by hand, which is nowhere documented and one of the pitfalls setting up new stores.

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    The store is not added in DB

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    after build also the store is not there

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    You need to add it by hand

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    okk

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    I have done that but http://yves.demo.spryker.local/ is not working i have created a store as demo so how can iaccess that store shop

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    Have you set SPRYKER_ACTIVE_STORES to DE,<Your Store> where is this const or variable i have to set

  • U04SA0H260N
    U04SA0H260N Posts: 30 🧑🏻‍🚀 - Cadet
    Options

    i am not getting any .env file

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 🪐 - Explorer
    Options

    This is an environment variable that is set into the container via the docker sdk.
    In your deploy.dev.yml add SPRYKER_ACTIVE_STORES: "DE, <YOUR STORE>" under:

    image:
      ...
      environment:
        SPRYKER_ACTIVE_STORES: "DE, <YOUR STORE>"
    

    Execute

    docker/sdk boot -s deploy.dev.yml
    docker/sdk up --build
    

    And your new store should be active