0

How can I remove or hide some of the columns from sales_order_grid. For example I want to hide next columns:

  1. Purchase point
  2. Ship to Name
  3. Signifyd Guarantee Decision

I tried with overriding sales_order_grid and adding visibility attribute as false, but nothing happened.

I want to hide them in Default View, and not to create new View with those columns disabled.

Thank you

2
  • Hi! Did you clean a cache? Dec 24, 2018 at 15:59
  • Yes, i am cleaning cache and static files after every change. Dec 24, 2018 at 16:04

2 Answers 2

4

You need to override

sales_order_grid.xml

as you said. Put this code into your module, file view/adminhtml/ui_component/sales_order_grid.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 *
 * file <Vendor>/<Module name>/view/adminhtml/ui_component/sales_order_grid.xml
 */
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="sales_order_columns">
        <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store">
            <settings>
                <label translate="true">Purchase Point</label>
                <bodyTmpl>ui/grid/cells/html</bodyTmpl>
                <sortable>false</sortable>
                <visible>false</visible>
                <controlVisibility>false</controlVisibility>
            </settings>
        </column>
        <column name="shipping_name">
            <settings>
                <filter>text</filter>
                <label translate="true">Ship-to Name</label>
                <visible>false</visible>
                <controlVisibility>false</controlVisibility>
            </settings>
        </column>
        <column name="signifyd_guarantee_status" component="Magento_Ui/js/grid/columns/select">
            <settings>
                <filter>select</filter>
                <options class="Magento\Signifyd\Ui\Component\Listing\Column\Guarantee\Options"/>
                <visible>false</visible>
                <dataType>select</dataType>
                <label translate="true">Signifyd Guarantee Decision</label>
                <controlVisibility>false</controlVisibility>
            </settings>
        </column>
    </columns>
</listing>

But, this only work for newly created users. For existing users, you need to truncate table ui_bookmark as you can see on link

For a detailed explanation, you can check following

My suggestion is to put that in UpgradeData file, for example

<?php

namespace <Vendor>\<Module name>\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

/**
 * Data upgrade script
 *
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class UpgradeData implements UpgradeDataInterface
{
    /**
     * {@inheritdoc}
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        if (version_compare($context->getVersion(), '1.0.2', '<')) {
            // Empty ui_bookmark table, so that new column's settings take power.
            $setup->getConnection()->truncateTable(
                $setup->getTable('ui_bookmark')
            );
        }

        $setup->endSetup();
    }
}

0

You can hide columns from grid page.

see screenshot

enter image description here

Just you have to check/uncheck those checkbox.

Thanks

1
  • As I said, I want to hide them in Default View, not to create new one. I want to remove that columns for all users so they don't need to do that manually like you say. Dec 25, 2018 at 10:02

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.