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

  • Hi! Did you clean a cache? – Evgeny Levinsky Dec 24 '18 at 15:59
  • Yes, i am cleaning cache and static files after every change. – user5526297 Dec 24 '18 at 16:04
0

You can hide columns from grid page.

see screenshot

enter image description here

Just you have to check/uncheck those checkbox.

Thanks

  • 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. – user5526297 Dec 25 '18 at 10:02
0

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();
    }
}

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.