简体   繁体   English

Shopware6:管理模块不可更新

[英]Shopware6 : Admin module not updatable

The default functionnality of Shopware does not shows the company name when we use the search bar in the admin panel.当我们使用管理面板中的搜索栏时,Shopware 的默认功能不会显示公司名称。 We have some customers only filling the company field and not using the first and lastName with text (they're adding "_" instead).我们有一些客户只填写公司字段,而不使用带有文本的名字和姓氏(他们正在添加“_”)。 So, I copied the structure from the vendor/shopware/administration/Resources/app/administration/src/app/component/structure/sw-search-bar-item/ in my custom theme and registered it in my main.js file but every change I made in my custom theme (sw-search-bar-item.html.twig) has no effects in the administration.因此,我从自定义主题中的vendor/shopware/administration/Resources/app/administration/src/app/component/structure/sw-search-bar-item/复制了结构并将其注册到我的 main.js 文件中,但是我在自定义主题 (sw-search-bar-item.html.twig) 中所做的每一项更改都不会影响管理。

Here's the default shopware file's content :这是默认的 shopware 文件的内容:

{% block sw_search_bar_item %}
<!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events -->
<li
    class="sw-search-bar-item sw-search-bar-item--v2"
    :class="componentClasses"
    @mouseenter="onMouseEnter($event)"
>

    {% block sw_search_bar_item_icon %}
    <sw-icon
        v-if="iconName"
        :name="iconName"
        :color="iconColor"
    />
    {% endblock %}

    {% block sw_search_bar_item_customer %}
    <router-link
        v-if="type === 'customer'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.customer.detail.base', params: { id: item.id } }"
        @click.native="onClickSearchResult('customer', item.id)"
    >
        {% block sw_search_bar_item_customer_label %}
        <span
            class="sw-search-bar-item__label"
        >
            {% block sw_search_bar_item_customer_label_name %}
                <sw-highlight-text
                        :search-term="searchTerm"
                        :text="`${item.firstName} ${item.lastName}`"
                />
            {% endblock %}

            {% block sw_search_bar_item_customer_label_number %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.customerNumber"
            />
            {% endblock %}
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_product %}
    <router-link
        v-else-if="type === 'product'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.product.detail.base', params: { id: item.id } }"
        @click.native="onClickSearchResult('product', item.id)"
    >

        {% block sw_search_bar_item_product_label %}
        <span
            class="sw-search-bar-item__label"
        >
            {% block sw_search_bar_item_product_label_name %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="productDisplayName"
            />
            {% endblock %}

            {% block sw_search_bar_item_product_label_number %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.productNumber"
            />
            {% endblock %}
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_category %}
    <router-link
        v-else-if="type === 'category'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.category.detail', params: { id: item.id } }"
        @click.native="onClickSearchResult('category', item.id)"
    >

        {% block sw_search_bar_item_category_label %}
        <span class="sw-search-bar-item__label">
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.name"
            />
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_order %}
    <router-link
        v-else-if="type === 'order'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.order.detail', params: { id: item.id } }"
        @click.native="onClickSearchResult('order', item.id)"
    >

        {% block sw_search_bar_item_order_label %}
        <span
            class="sw-search-bar-item__label"
        >
            {% block sw_search_bar_item_order_label_name %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="`${item.orderCustomer.firstName} ${item.orderCustomer.lastName}`"
            />
            {% endblock %}

            {% block sw_search_bar_item_order_label_number %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.orderNumber"
            />
            {% endblock %}
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_media %}
    <router-link
        v-else-if="type === 'media'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.media.index', params: { folderId: item.mediaFolderId }, query: { term: item.fileName } }"
        @click.native="onClickSearchResult('media', item.id)"
    >

        {% block sw_search_bar_item_media_label %}
        <span class="sw-search-bar-item__label">
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item | mediaName"
            />
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_cms_page %}
    <router-link
        v-else-if="type === 'cms_page'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.cms.detail', params: { id: item.id } }"
        @click.native="onClickSearchResult('cms_page', item.id)"
    >

        {% block sw_search_bar_item_cms_page_label %}
        <span class="sw-search-bar-item__label">
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.name"
            />
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_landing_page %}
    <router-link
        v-else-if="type === 'landing_page'"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: 'sw.category.landingPageDetail.base', params: { id: item.id } }"
        @click.native="onClickSearchResult('landing_page', item.id)"
    >

        {% block sw_search_bar_item_cms_landing_page_label %}
        <span class="sw-search-bar-item__label">
            <sw-highlight-text
                :search-term="searchTerm"
                :text="item.name"
            />
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_module %}
    <router-link
        v-else-if="['frequently_used', 'module'].includes(type)"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="routeName"
    >
        {% block sw_search_bar_item_module_label %}
        <span
            class="sw-search-bar-item__label"
        >
            {% block sw_search_bar_item_module_label_module %}
            <sw-highlight-text
                :search-term="searchTerm"
                :text="moduleName"
            />
            {% endblock %}

            {% block sw_search_bar_item_module_label_shortcut %}
            <sw-shortcut-overview-item
                v-if="shortcut"
                title=""
                :content="shortcut"
            />
            {% endblock %}

            {% block sw_search_bar_item_module_label_action %}
            <sw-highlight-text
                :text="$tc(`global.sw-search-bar-item.${item.action ? 'typeLabelAction': 'typeLabelModule'}`)"
            />
            {% endblock %}
        </span>
        {% endblock %}
    </router-link>
    {% endblock %}

    {% block sw_search_bar_item_other_entity %}
    <router-link
        v-else-if="detailRoute && displayValue.length > 0"
        ref="routerLink"
        class="sw-search-bar-item__link"
        :to="{ name: detailRoute, params: { id: item.id } }"
    >

        {% block sw_search_bar_item_other_entity_label %}
        <span class="sw-search-bar-item__label">
            <sw-highlight-text
                :search-term="searchTerm"
                :text="displayValue"
            />
        </span>
        {% endblock %}

    </router-link>
    {% endblock %}
</li>
{% endblock %}

and here are the lines I need to change : :text=" ${item.firstName} ${item.lastName} " :text=" ${item.orderCustomer.firstName} ${item.orderCustomer.lastName} "这是我需要更改的行: :text=" ${item.firstName} ${item.lastName} " :text=" ${item.orderCustomer.firstName} ${item.orderCustomer.lastName} "

I just copied the whole content in the previous file and changed these two lines to : :text=" ${item.firstName} ${item.lastName} ${item.company} "我只是复制了前一个文件中的全部内容并将这两行更改为: :text=" ${item.firstName} ${item.lastName} ${item.company} "

:text=" ${item.orderCustomer.firstName} ${item.orderCustomer.lastName} ${item.orderCustomer.company} " :text=" ${item.orderCustomer.firstName} ${item.orderCustomer.lastName} ${item.orderCustomer.company} "

Is there something wrong?有什么不对?

Here's my main.js file content :这是我的 main.js 文件内容:

import './app/component/structure/sw-search-bar-item';导入'./app/component/structure/sw-search-bar-item';

You can see my folder's structure in the attached picture您可以在附图中看到我的文件夹结构在此处输入图像描述

I think you have to overwrite the twig template in a different way as it is included from Javascript:我认为您必须以不同的方式覆盖树枝模板,因为它包含在 Javascript 中:

The first parameter is component to override and second parameter is new twig template for this component.第一个参数是要覆盖的组件,第二个参数是该组件的新树枝模板。

import template from './src/extension/sw-order-detail/sw-order- detail.html.twig';从'./src/extension/sw-order-detail/sw-order-detail.html.twig'导入模板; Component.override('sw-order-detail', { template, }); Component.override('sw-order-detail', { template, });

See here for the source https://webkul.com/blog/how-to-override-a-component-in-shopware-6/请参阅此处获取源https://webkul.com/blog/how-to-override-a-component-in-shopware-6/

显然,这是来自其他地方的问题,因为我只是在另一个实例上复制了相同的文件和相同的内容......它工作得很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM