Shopware 6:如何添加到自定义插件配置单序列中的国家列表

发布于 2025-01-22 07:07:03 字数 696 浏览 4 评论 0原文

对于创建单选项列表,我们有:

        <input-field type="single-select">
            <name>currentCountry</name>
            <label>Current country</label>
            <required>true</required>
            <options>
                <option>
                    <id>..</id>
                    <name>...</name>
                </option>
                <option>
...
                </option>
            </options>
        </input-field>

但是,如果我们想显示SW中已经存在的国家列表,该怎么办?

我们可以指定实体的来源,以便将其转换为所需的格式吗? 在Magento 2中,我们有这样的机会,SW是否支持类似的东西,或者在某个阶段可以替代必要的数据以便不在XML中形成永久列表?

For the creation single select list we have:

        <input-field type="single-select">
            <name>currentCountry</name>
            <label>Current country</label>
            <required>true</required>
            <options>
                <option>
                    <id>..</id>
                    <name>...</name>
                </option>
                <option>
...
                </option>
            </options>
        </input-field>

But what if we want to show the list of countries that already exist in SW?

Can we specify the source of the entity so that it can be transformed into the desired format?
In Magento 2, we have such an opportunity, does SW support something similar, or is it possible at some stage to substitute the necessary data there so as not to form a permanent list in xml?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘亓 2025-01-29 07:07:03

您可以具有自定义组件并将所需的实体传递给它。
It's written within the Documentation - There's an example for an

只需在&lt; entity&gt;中指定实体 - 在这种情况下,实体被称为country 。您可以看一下

因此,一个完整的工作示例是:

<component name="sw-entity-single-select">
    <name>shopwareCountries</name>
    <entity>country</entity>
    <label>Choose a country</label>
</component>

示例屏幕:

”插件配置中的sw-entity-single-select”

You can have a custom component and pass the required entity to it.
It's written within the Documentation - There's an example for an Entity single select for products

Just specify the Entity within <entity> - The entity in this case is called country. You can take a look at the CountryDefinition.

So a full working example would be:

<component name="sw-entity-single-select">
    <name>shopwareCountries</name>
    <entity>country</entity>
    <label>Choose a country</label>
</component>

Example Screen:

sw-entity-single-select within plugin configuration

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文