Skip to content

Create new store with existing stores with config.php #24584

@klict

Description

@klict

Preconditions (*)

1.Magento 2.3.2
2.php7.2
3.have few stores installed with products and categories

Steps to reproduce (*)

  1. Create or modify config.php file
return [
    'modules' => [ /** enabled modules **/],
    'scopes' => [
        'websites' => [
            'existing1' => [
                'website_id' => '0',
                'code' => 'existing1',
                'name' => 'Existing1 Website',
                'sort_order' => '0',
                'default_group_id' => '0',
                'is_default' => '0'
            ],
            'existing2' => [
                'website_id' => '1',
                'code' => 'existing2',
                'name' => 'Existing2 Website',
                'sort_order' => '0',
                'default_group_id' => '1',
                'is_default' => '1'
            ],
            'toBeCreated' => [
                'website_id' => '2',
                'code' => 'toBeCreated',
                'name' => 'To Be Created Website',
                'sort_order' => '1',
                'default_group_id' => '2',
                'is_default' => '0'
            ],
        ],
        'groups' => [
            [
                'group_id' => '0',
                'website_id' => '0',
                'name' => 'Existing1 Store',
                'root_category_id' => '0',
                'default_store_id' => '0',
                'code' => 'existing1'
            ],
            [
                'group_id' => '1',
                'website_id' => '1',
                'name' => 'Existing2 Store',
                'root_category_id' => '2',
                'default_store_id' => '1',
                'code' => 'main_website_store'
            ],
            [
                'group_id' => '2',
                'website_id' => '2',
                'name' => 'To Be Created Store',
                'root_category_id' => '2',
                'default_store_id' => '2',
                'code' => 'toBeCreated'
            ]
        ],
        'stores' => [
            'existing1' => [
                'store_id' => '0',
                'code' => 'existing1',
                'website_id' => '0',
                'group_id' => '0',
                'name' => 'Existing1 Store View',
                'sort_order' => '0',
                'is_active' => '1'
            ],
            'existing2' => [
                'store_id' => '1',
                'code' => 'existing2',
                'website_id' => '1',
                'group_id' => '1',
                'name' => 'Existing2 Store View',
                'sort_order' => '0',
                'is_active' => '1'
            ],
            'toBeCreated' => [
                'store_id' => '2',
                'code' => 'toBeCreated',
                'website_id' => '2',
                'group_id' => '2',
                'name' => 'ToBeCreated Store View',
                'sort_order' => '1',
                'is_active' => '1'
            ],
        ]
    ]
];
  1. run bin/magento setup:upgrade

Expected result (*)

These Websites will be updated: Existing1 Website, Existing2 Website
These Websites will be created: To Be Created Website
These Groups will be updated: Existing1 Store, Existing2 Store
These Groups will be created: To Be Created Store
These Stores will be updated: Existing1 Store View, Existing2 Store View
These Stores will be created: ToBeCreated Store View
Do you want to continue [yes/no]?
yes
Stores were processed
The following new store groups must be associated with a root category: To Be Created Store. 

Actual result (*)

  1. I get following message Import failed: Validation Failed
  2. From exception.log file:

[2019-09-13 11:40:01] report.ERROR: Validation Failed {"exception":"[object] (Magento\Framework\Exception\State\InvalidTransitionException(code: 0): Validation Failed at /home/user/Documents/dev/project/project-magento/vendor/magento/module-store/Model/Config/Importer.php:115, Magento\Framework\Exception\RuntimeException(code: 0): Validation Failed at /home/user/Documents/dev/project/project-magento/vendor/magento/module-store/Model/Config/Importer/Processor/Create.php:123, Magento\Framework\Validation\ValidationException(code: 0): Validation Failed at /home/user/Documents/dev/project/project-magento/vendor/magento/module-inventory/Model/Stock/Command/Save.php:59)"}

Useful notes

The app:config:import command does not fail and if you run setup:upgrade command twice it will succeed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions