Upgrade the CmsBlockStorage module
Edit on GitHubUpgrading from version 1.* to version 2.*
CmsBlockStorage version 2.0.0 introduces the following backward incompatible changes:
- Introduced the
spy_cms_block_storage.cms_block_keyfield to store thecms_blockidentifier. - Introduced the
mappingsparameter to synchronization behavior to support the ability to get data by block names. - Increased the minimum
spryker/cms-blockversion incomposer.json. See Upgrade the CmsBlock module for more details. - Removed
CmsBlockStorageClient::findBlockNamesByOptions(). - Removed
CmsBlockStorageClientInterface::generateBlockNameKey(). - Added return type as an array to
CmsBlockStorageClientInterface::findBlocksByNames().
Estimated migration time: 1h
-
Upgrade to the new module version:
- Upgrade the
CmsBlockStoragemodule to version 2.0.0:
composer require spryker/cms-block-storage:"^2.0.0" --update-with-dependencies - Upgrade the
-
Clear storage:
- Truncate the
spy_cms_block_storagedatabase table:
TRUNCATE TABLE spy_cms_block_storage- Remove all keys from key-value storage (Redis or Valkey):
redis-cli --scan --pattern kv:cms_block:'*' | xargs redis-cli unlink - Truncate the
-
Update the database schema and generate classes:
- Run the database migration:
console propel:install- Generate transfer objects:
console transfer:generate -
Populate storage with the new version:
- Get all the data about CMS blocks from database and publish it into key-value storage (Redis or Valkey):
console event:trigger -r cms_block-
Verify that the
spy_cms_block_storage.keycolumn uses keys instead of IDs. For example,cms_block:en_us:blck-1, whereblck-1is the CMS block key. -
Verify that all the method overrides in
\Pyz\Zed\CmsBlockStorage\CmsBlockStorageDependencyProvidermatch the signature provided in the package:
protected function getContentWidgetDataExpanderPlugins(): array -
Optional: Enable CMS Block Key support for categories and products:
- Install CMS block key support for
CmsBlockCategoryStorageandCmsBlockProductStoragemodules:
composer require spryker/cms-block-category-storage:"^1.4.0" spryker/cms-block-product-storage:"^1.4.0" --update-with-dependencies- Add plugins in
src/Pyz/Client/CmsBlockStorage/CmsBlockStorageDependencyProvider.php:
namespace Pyz\Client\CmsBlockStorage; use Spryker\Client\CmsBlockCategoryStorage\Plugin\CmsBlockStorage\CmsBlockCategoryCmsBlockStorageReaderPlugin; use Spryker\Client\CmsBlockProductStorage\Plugin\CmsBlockStorage\CmsBlockProductCmsBlockStorageReaderPlugin; use Spryker\Client\CmsBlockStorage\CmsBlockStorageDependencyProvider as SprykerCmsBlockStorageDependencyProvider; class CmsBlockStorageDependencyProvider extends SprykerCmsBlockStorageDependencyProvider { /** * @return \Spryker\Client\CmsBlockStorageExtension\Dependency\Plugin\CmsBlockStorageReaderPluginInterface[] */ protected function getCmsBlockStorageReaderPlugins(): array { return [ new CmsBlockCategoryCmsBlockStorageReaderPlugin(), new CmsBlockProductCmsBlockStorageReaderPlugin(), ]; } }- Trigger sync events:
console event:trigger -r cms_block_category console event:trigger -r cms_block_product - Install CMS block key support for
Thank you!
For submitting the form