magento / architecture

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

Proposal for configuration provisioning #370

Open sydekumf opened 4 years ago

sydekumf commented 4 years ago

Problem

When you start a new Magento project there are similar initial tasks to set up configuration including websites, stores, tax, store configuration, attributes and more which lead to different problems:

Solution

There should be a declarative schema approach to provision a new instance with all necessary configuration to run. It is related to the existing delcarative database schema but manages configuration data like:

Requested Reviewers

@buskamuza @paliarush

buskamuza commented 4 years ago

I agree that the declarative approach is always better than imperative, and having declarative data scripts has drawbacks. So having declarative data definitions would be a huge improvement. Regarding the current proposal:

  1. I would change terminology from "configuration" to "data". What is described is storing entities in the storage (web sites, stores, etc). So those are the same things as the ones handled by data scripts currently.
  2. The challenging part, as also mentioned in the document, is the modifications. Here we would need to cover questions like "what happens if the data has already been removed when we try to update/delete it?", "how to declare modifications that rely on existing data" (something that can't be declarative). In general, I would first question the necessity of the declarative data for upgrade scenario. From the problem statement, it looks like we need these declarations for initial setup only. In this case install scenario will be sufficient. It would reduce complexity of the solution, IMO. Then data scripts will continue performing the role of "modifiers" (they would modify existing data), while declarative data would be executed only once. It can be during installation, or it might be ok to apply data during setup:upgrade, just to make sure it's only once.
  3. It would be good to cover whether existing data scripts should be transformed in the declarative representation. Or whether only some of the upgrades should be converted.
  4. If target audience for this feature is SIs, maybe it the framework should support location of those declarations in app/etc (as part of a specific project). While they can also be located in modules to support essential data (like websites), w/o which the module can't work.
buskamuza commented 4 years ago

Scheduled meeting to discuss: https://adobe.bluejeans.com/7385677850 , Thursday, May 28, 10am (CDT)

mslabko commented 4 years ago

@sydekumf Did you try https://github.com/magento/magento2ce/blob/2.4-develop/setup/performance-toolkit/profiles/ce/small.xml? (docs: https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-perf-data.html)

vgoncharenko commented 4 years ago

@mslabko I guess profile generator has too general approach for generation. entities like 'Store 1' and 'Store 2' rarely used in real online stores. @sydekumf by the way, what is the difference between data import and this approach? The names of entities would be different each time anyway. CSV is not so hard to manage comparison to XML/JSON or whatever format you would like to pick. And even if import isn't the option, you always can create own sample-data configuration and use it. if I'm not mistaken it use CSV config types as well.

akaplya commented 4 years ago

It could be quite uncertain. Due Magento saves the mentioned entities in a database the introduction of config like this will cause the question is this data that were declared can be edited? What should happen if the module disabled or removed?

The common recommendation never setup new EAV attributes through the application installation because the stores, attributes, and sets are something that should be managed by a merchant and we can not rely on this information presence in code.

The proper solution for the case you mentioned will be data import.

buskamuza commented 4 years ago

Meeting minutes:

Action items:

akaplya commented 4 years ago

@sydekumf one more question, in the examples you mentioned could EAV attributes be replaced with extension attributes which are already declarative? https://devdocs.magento.com/guides/v2.3/extension-dev-guide/attributes.html#extension

sydekumf commented 4 years ago

Hi @buskamuza we updated the proposal with the information from our last call :-) Could you please have a look into it. We would be very happy to talk about that with you in another call. Let me know what you think, thanks a lot!

sydekumf commented 4 years ago

We simplified the concept and updated the document :-)

buskamuza commented 4 years ago

@fascinosum : How events on configuration update will be covered? May be not an issue for initial installation, but may lead to unexpected behavior during update.

buskamuza commented 4 years ago

Regarding required attributes: agreed that as this is an existing problem, it's not necessarily should be addressed in this proposal. A default value should be used for attributes whenever possible, in this case it can be used to fill data for existing records.

sydekumf commented 3 years ago

@buskamuza How can we proceed with this PR? Would be happy to get any news or plans from Adobe/Magento :-) Thanks!