infrangible / m2-widget-theme-copy
Console command for Magento 2 that copies the widgets of one theme to another theme, for example after switching the store to a new or child theme.
Package info
github.com/infrangible-dev/m2-widget-theme-copy
Type:magento2-module
pkg:composer/infrangible/m2-widget-theme-copy
Requires
- php: >=8.1
- infrangible/m2-core: ~5.0.6
- infrangible/m2-foundation: ~3.0.2
- magento/framework: ~103.0.6
- magento/module-theme: ~101.1.6
- magento/module-widget: ~101.2.6
- symfony/console: ~5.4.0||~6.4.0||~7.4.0
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-27 15:09:35 UTC
README
Magento assigns every widget (Content > Widgets) to a theme. When a store switches to another theme, for example a child theme or a new theme, the widgets of the previous theme are not shown anymore: CMS blocks in the footer, on the home page or in categories disappear until they are assigned to the new theme one by one. This module adds a console command that copies all widgets of one theme to another theme in one step.
Usage
bin/magento widget:theme:copy --from Magento/luma --to Vendor/theme
--fromand--to: the themes as shown in Content > Design > Themes, for exampleMagento/luma(frontend/Magento/lumaworks too).--dry-run: lists what would be copied, without changing anything.--replace: widgets that the target theme already has with the same type and title are replaced by a new copy. By default they are skipped, so the command can run more than once without creating duplicates.
Every widget is copied with its title, store views, parameters, sort order and page assignments (all pages, specific pages or categories, page layouts), exactly as if it was saved for the other theme in the admin. Afterwards the caches for layouts, blocks and pages are cleaned. The widgets of the source theme are kept.
Run the command after installing the new theme (setup:upgrade), before or after selecting it in Content > Design >
Configuration; try it with --dry-run first, and on a staging system before production.
Requirements
- Magento Open Source or Adobe Commerce 2.4.6 or newer
- PHP 8.1 or newer
Installation
composer require infrangible/m2-widget-theme-copy bin/magento module:enable Infrangible_WidgetThemeCopy bin/magento setup:upgrade
In production mode, also run bin/magento setup:di:compile.
License
Infrangible Widget Theme Copy is licensed under the MIT License - see the LICENSE file for details.