i m overriding above code in di.xml file in magento2

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <argument name="collections" xsi:type="array">
            <item name="sales_order_grid_data_source" xsi:type="string">Knight\Noecom\Model\ResourceModel\Order\Grid\Collection</item>
  • can you please add your overriding code here ? – Aasim Goriya Nov 27 '18 at 5:28

i just found solution by my own just override your sales_order_grid.xml file and put below code to remove create an order button hope anyone get help from it :

<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="componentDisabled" xsi:type="boolean">true</item> //add this line which disable your button
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item>
            <item name="deps" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item>
        <item name="spinner" xsi:type="string">sales_order_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">Create An Order</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>

In sales_order_grid.xml there is code to display button 'create an order' at line#15

you can simply hide below code in your override XML file line#15

            <button name="add">
                <url path="sales/order_create/start"/>
                <label translate="true">Create New Order</label>

run below commands after changes

php bin/magento cache:clean && php bin/magento cache:flush
  • its not a good idea to changes in core files – Aasim Goriya Nov 27 '18 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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