2

How to remove "Add New Customer" in Index Admin Customer:
enter image description here

I created a new module:
Create 2 file:
1) NameSpace/Module/view/adminhtml/layout/customer_index_index.xml

<?xml version="1.0" encoding="UTF-8"?>
<referenceContainer name="content">
    <uiComponent name="customer_listing">
    </uiComponent>
</referenceContainer>

2) NameSpace/Module/view/adminhtml/ui_component/customer_listing.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">customer_listing.customer_listing_data_source</item>
            <item name="deps" xsi:type="string">customer_listing.customer_listing_data_source</item>
        </item>
        <item name="spinner" xsi:type="string">customer_columns</item>
        <item name="buttons" xsi:type="array" >
            <item name="add" xsi:type="array">
                <item name="name" xsi:type="string">add</item>
                <item name="label" xsi:type="string" translate="true">Add New Customer</item>
                <item name="class" xsi:type="string">primary</item>
                <item name="url" xsi:type="string">*/*/new</item>
                <item name="style" xsi:type="string">display:none</item>
            </item>
        </item>
    </argument>
    <dataSource name="customer_listing_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\DataProvider</argument>
            <argument name="name" xsi:type="string">customer_listing_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">entity_id</argument>
            <argument name="requestFieldName" xsi:type="string">id</argument>
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="update_url" xsi:type="url" path="mui/index/render"/>
                </item>
            </argument>
        </argument>
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
            </item>
        </argument>
    </dataSource>
    <container name="listing_top">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="template" xsi:type="string">ui/grid/toolbar</item>
            </item>
        </argument>
        <bookmark name="bookmarks">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="storageConfig" xsi:type="array">
                        <item name="namespace" xsi:type="string">customer_listing</item>
                    </item>
                </item>
            </argument>
        </bookmark>
        <component name="columns_controls">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="columnsData" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.customer_columns</item>
                    </item>
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item>
                    <item name="displayArea" xsi:type="string">dataGridActions</item>
                </item>
            </argument>
        </component>
        <exportButton name="export_button">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="selectProvider" xsi:type="string">customer_listing.customer_listing.customer_columns.ids</item>
                </item>
            </argument>
        </exportButton>
        <filterSearch name="fulltext">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="provider" xsi:type="string">customer_listing.customer_listing_data_source</item>
                    <item name="chipsProvider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters_chips</item>
                    <item name="storageConfig" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks</item>
                        <item name="namespace" xsi:type="string">current.search</item>
                    </item>
                </item>
            </argument>
        </filterSearch>
        <filters name="listing_filters">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="columnsProvider" xsi:type="string">customer_listing.customer_listing.customer_columns</item>
                    <item name="storageConfig" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks</item>
                        <item name="namespace" xsi:type="string">current.filters</item>
                    </item>
                    <item name="childDefaults" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.listing_filters</item>
                        <item name="imports" xsi:type="array">
                            <item name="visible" xsi:type="string">customer_listing.customer_listing.customer_columns.${ $.index }:visible</item>
                        </item>
                    </item>
                </item>
            </argument>
        </filters>
        <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="selectProvider" xsi:type="string">customer_listing.customer_listing.customer_columns.ids</item>
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
                    <item name="indexField" xsi:type="string">entity_id</item>
                </item>
            </argument>
            <action name="delete">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="type" xsi:type="string">delete</item>
                        <item name="label" xsi:type="string" translate="true">Delete</item>
                        <item name="url" xsi:type="url" path="customer/index/massDelete"/>
                        <item name="confirm" xsi:type="array">
                            <item name="title" xsi:type="string" translate="true">Delete items</item>
                            <item name="message" xsi:type="string" translate="true">Are you sure to delete selected customers?</item>
                        </item>
                    </item>
                </argument>
            </action>
            <action name="subscribe">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="type" xsi:type="string">subscribe</item>
                        <item name="label" xsi:type="string" translate="true">Subscribe to Newsletter</item>
                        <item name="url" xsi:type="url" path="customer/index/massSubscribe"/>
                    </item>
                </argument>
            </action>
            <action name="unsubscribe">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="type" xsi:type="string">unsubscribe</item>
                        <item name="label" xsi:type="string" translate="true">Unsubscribe from Newsletter</item>
                        <item name="url" xsi:type="url" path="customer/index/massUnsubscribe"/>
                        <item name="confirm" xsi:type="array">
                            <item name="title" xsi:type="string" translate="true">Unsubscribe from Newsletter</item>
                            <item name="message" xsi:type="string" translate="true">Are you sure to unsubscribe selected customers from newsletter?</item>
                        </item>
                    </item>
                </argument>
            </action>
            <action name="assign_to_group">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="type" xsi:type="string">assign_to_group</item>
                        <item name="label" xsi:type="string" translate="true">Assign a Customer Group</item>
                    </item>
                </argument>
................................
...................................
</listing>

When I removed "Add New Customer" by remove some code in this xml file:

<argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">customer_listing.customer_listing_data_source</item>
            <item name="deps" xsi:type="string">customer_listing.customer_listing_data_source</item>
        </item>
        <item name="spinner" xsi:type="string">customer_columns</item>
        <item name="buttons" xsi:type="array" >
            <item name="add" xsi:type="array">
                <item name="name" xsi:type="string">add</item>
                <item name="label" xsi:type="string" translate="true">Add New Customer</item>
                <item name="class" xsi:type="string">primary</item>
                <item name="url" xsi:type="string">*/*/new</item>
                <item name="style" xsi:type="string">display:none</item>
            </item>
        </item>
    </argument>

But it reused original core layout,Anyone know, show me pls!Thanks!

2 Answers 2

4

Add

<item name="componentDisabled" xsi:type="boolean">true</item>

to

 <item name="add" xsi:type="array">
 </item>
3
  • I tried but it not change anything .
    – MrTo-Kane
    Commented Mar 3, 2016 at 2:11
  • Yes! I remove all content in : <item name="add" xsi:type="array"> </item> and paste : <item name="componentDisabled" xsi:type="boolean">true</item> then it worked ! Thanks @Arkadii Chyzhov !
    – MrTo-Kane
    Commented Mar 3, 2016 at 2:31
  • I tried to remove "company" field from checkout but had no success. Could you help? <item name="company" xsi:type="array"> <item name="config" xsi:type="array"> <item name="componentDisabled" xsi:type="boolean">true</item> </item> </item> Commented May 18, 2016 at 21:48
1

Rename customer_listing.xml to customer_custom_listing.xml and also update the new filename in NameSpace/Module/view/adminhtml/layout/customer_index_index.xml

 <?xml version="1.0" encoding="UTF-8"?>
<referenceContainer name="content">
    <uiComponent name="customer_custom_listing">
    </uiComponent>
</referenceContainer>

Now you can delete the below lines from customer_custom_listing.xml to remove the button.

<item name="buttons" xsi:type="array" >
            <item name="add" xsi:type="array">
                <item name="name" xsi:type="string">add</item>
                <item name="label" xsi:type="string" translate="true">Add New Customer</item>
                <item name="class" xsi:type="string">primary</item>
                <item name="url" xsi:type="string">*/*/new</item>
                <item name="style" xsi:type="string">display:none</item>
            </item>
        </item>
1
  • I tried to do this way, but it not remove button, and it generate button of original layout.
    – MrTo-Kane
    Commented Mar 3, 2016 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.