Search code examples
shopwareshopware6

Show (and sort by) customer registration time in Shopware 6 administration


Can we add customer registration time column in Shopware 6 administration Customers Overview? Is there a feature or should we develop an extension for this?


Solution

  • Since you just asked a question about overriding components. Have you ever tried to take a look at these components to understand how they work? That should be your first step and maybe then you wouldn't have to ask the question in the first place.

    To answer your question: Yes, you have to write an extension.

    const { Component } = Shopware;
    
    Component.override('sw-customer-list', {
        template,
        
        methods: {
            getCustomerColumns() {
                const columns = this.$super('getCustomerColumns');
    
                columns.push({
                    property: 'createdAt',
                    label: 'Registered/Created at',
                    allowResize: true,
                    visible: true,
                    useCustomSort: true,
                });
    
                return columns;
            },
        },
    });
    
    {% block sw_customer_list_grid_columns %}
        {% parent %}
        <template #column-createdAt="{ item }">
            {{ item.createdAt | date({hour: '2-digit', minute: '2-digit'}) }}
        </template>
    {% endblock %}