为什么无法复制 Shopware 6 中的子主题?

huangapple go评论71阅读模式
英文:

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?)

为什么无法复制 Shopware 6 中的子主题?

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(() =&gt; {
        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(() =&gt; {
        this.$router.push({ name: &#39;sw.theme.manager.detail&#39;, params: { id: themeDuplicate.id } });
    });
},

huangapple
  • 本文由 发表于 2023年6月29日 15:52:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579059.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定