Migration Guide - CMS Block
This version allows to save CMS Block-Store relation.
- Update spryker/cms-block module to at least Version 2.0.0.
Update your spryker/cms-block-collector module to at least Version 2.0.0.
You can find additional guide to migration here.
Custom CMS Block CollectorIf you have a custom CMS Block Collector, make sure that it collects CMS Blocks only when the related CMS Block has an entity in the spy_cms_block_store table for the desired store.
Run vendor/bin/console transfer:generate to update and generate transfer object changes.
Transfer object changes
- CmsBlock transfer object has now a StoreRelation property which allows to retrieve/define the stores assigned to the current CMS Block.
- Install the database changes by running vendor/bin/console propel:diff. Propel should generate a migration file with the changes.
- Apply the database changes: vendor/bin/console propel:migrate.
- Generate and update ORM models: vendor/bin/console propel:model:build.
You will find some new classes in your project under \Orm\Zed\CmsBlock\Persistence namespace. It’s important to make sure that they extend the base classes from the Spryker core, e.g.:
- \Orm\Zed\CmsBlock\Persistence\SpyCmsBlockStore extends \Spryker\Zed\CmsBlock\Persistence\Propel\AbstractSpyCmsBlockStore
- \Orm\Zed\CmsBlock\Persistence\SpyCmsBlockStoreQuery extends \Spryker\Zed\CmsBlock\Persistence\Propel\AbstractSpyCmsBlockStoreQuery
The newly created spy_cms_block_store table defines 1 row per CMS Block-store association. Populate this table according to your requirements.
- You have the following CMS Blocks: Block_1, Block_2.
- You have the following stores: AT, DE, US.
The spy_cms_block_store can have a configuration like this:
FK_CMS_BLOCK FK_STORE Block_1 AT Block_1 DE Block_1 US Block_2 AT
This example defines "Block_1" to be enabled in all of your stores, but restricts "Block_2" to AT store only.
IMPORTANT: even if you have 1 store, the associations between CMS Blocks and stores have to be defined.Example migration query
To populate the new spy_cms_block_store table to have all CMS Blocks in all stores as an initial configuration, run the following query:
PostgreSQL: INSERT INTO spy_cms_block_store (id_cms_block_store, fk_cms_block, fk_store) SELECT nextval('id_cms_block_store_pk_seq'), id_cms_block, id_store FROM spy_cms_block, spy_store; MySQL: INSERT INTO spy_cms_block_store (fk_cms_block, fk_store) SELECT id_cms_block, id_store FROM spy_cms_block, spy_store;
Additionally, the following internal classes/methods have changed. Take a look if you have customized them:
CMS Block is ready to be used in multi-store environment. Additionally you might want to update the spryker/cms-block-gui Administration Intervace to manage CMS Blocks and their store configuration. You can find further information about multi-store CMS Blocks here, and Zed Admin UI module migration guide here.
- Learn how to migrate CMS Block Collector
- Learn how to migrate CMS Block GUI
- Learn more about Multi-store CMS Block
- Learn how to use CMS blocks
Last review date: Jan 31, 2018