英文:
Why can't we copy a child theme in Shopware 6?
问题
我们正在使用购买的主题(Horzion PRO),并按照他们的指南创建了一个子主题以进行一些小的调整。
现在我们需要创建几个销售渠道,这些渠道应该具有基本相同的设计,包括那些调整,但在颜色等方面有所更改。
这些颜色可以在Shopware管理面板中更改。因此,通常我们会通过管理面板创建一个副本来创建不同的自定义数据集(这就是此功能的作用吗?)
很不幸,对于子主题来说,复制主题的功能是<strike>灰色的</strike> 缺失的。
这是出现这种情况的技术原因是什么?这个问题能修复吗?
我们知道一个解决方法是复制并粘贴子主题5次,但我们宁愿避免这样做,也考虑到将来的更新。
我们目前使用的是Shopware 6.4,但如果在这方面有任何改进,我们可以升级到6.5。
英文:
We are using a purchased theme (Horzion PRO) and created a sub theme as per their guide to make some small adjustments.
Now we need to create several sales channels which should have basically the same design, include those adjustments, but have changes in colors and so on.
Those colors can be changed in the Shopware admin panel. So we usually would create a duplicate via the admin panel to create a different customization data set (is this what this function does?)
Unfortunately the duplicate theme function is <strike>grayed out</strike> missing for the Child theme.
What is the technical reason for this? Is this fixable?
We know one workaround would be to copy&paste the child them 5 times, but we'd rather like to avoid this also having future updates in mind.
We are currently on Shopware 6.4 but can upgrade to 6.5 if there is any improvement in this regards.
答案1
得分: 2
在子主题上还是一般情况下都是灰色的?这可能表明菜单选项被禁用。查看模板,只有当用户缺少相应的角色权限theme.creator
时,该选项才会被禁用。我看不出其他任何原因,该选项应该被禁用。
如果一切都失败了,您可以自己在theme
表中创建新记录。供参考,这是创建新记录的代码,其中parentTheme
是要复制的主题。
duplicateTheme(parentTheme, name) {
const themeDuplicate = this.themeRepository.create(Shopware.Context.api);
themeDuplicate.name = name;
themeDuplicate.parentThemeId = parentTheme.id;
themeDuplicate.author = parentTheme.author;
themeDuplicate.description = parentTheme.description;
themeDuplicate.labels = parentTheme.labels;
themeDuplicate.helpTexts = parentTheme.helpTexts;
themeDuplicate.customFields = parentTheme.customFields;
themeDuplicate.baseConfig = null;
themeDuplicate.configValues = null;
themeDuplicate.previewMediaId = parentTheme.previewMediaId;
themeDuplicate.active = true;
this.themeRepository.save(themeDuplicate, Shopware.Context.api).then(() => {
this.$router.push({ name: 'sw.theme.manager.detail', params: { id: themeDuplicate.id } });
});
},
英文:
Is it only grayed out on the child theme or in general? This would suggest that the menu option is disabled. Looking at the template the option is only disabled if the user is missing the corresponding role permission theme.creator
. I can't see any other reason, why the option should be disabled otherwise.
If all fails you can simply create the new record in the theme
table yourself. For reference this is the code that creates the new record where parentTheme
is the theme to be duplicated.
duplicateTheme(parentTheme, name) {
const themeDuplicate = this.themeRepository.create(Shopware.Context.api);
themeDuplicate.name = name;
themeDuplicate.parentThemeId = parentTheme.id;
themeDuplicate.author = parentTheme.author;
themeDuplicate.description = parentTheme.description;
themeDuplicate.labels = parentTheme.labels;
themeDuplicate.helpTexts = parentTheme.helpTexts;
themeDuplicate.customFields = parentTheme.customFields;
themeDuplicate.baseConfig = null;
themeDuplicate.configValues = null;
themeDuplicate.previewMediaId = parentTheme.previewMediaId;
themeDuplicate.active = true;
this.themeRepository.save(themeDuplicate, Shopware.Context.api).then(() => {
this.$router.push({ name: 'sw.theme.manager.detail', params: { id: themeDuplicate.id } });
});
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论