When our customer service people need to copy an order number from the Admin Order Grid, they try and highlight it with their cursor and copy it but that triggers the standard M2 click action to show the order.
I need to be able to remove the URL from the ID cell or alternatively the whole row in the order grid only. We can still edit the order by clicking the "edit" link but the whole row being clickable is causing problems.
Would appreciate your help.
-
Please try this link magento.stackexchange.com/questions/225083/…Msquare– Msquare2020年04月03日 15:16:14 +00:00Commented Apr 3, 2020 at 15:16
2 Answers 2
Try the following way:
app/code/SR/MagentoCommunity/view/adminhtml/ui_component/sales_order_grid.xml
<?xml version="1.0" encoding="UTF-8"?>
<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" class="SR\MagentoCommunity\Ui\Component\Columns"/>
</listing>
app/code/SR/MagentoCommunity/Ui/Component/Columns.php
<?php
declare(strict_types=1);
namespace SR\MagentoCommunity\Ui\Component;
class Columns extends \Magento\Ui\Component\Listing\Columns
{
public function prepare()
{
$config = $this->getData('config');
if (isset($config['childDefaults']['fieldAction'])) {
unset($config['childDefaults']['fieldAction']);
}
$this->setData('config', (array)$config);
parent::prepare();
}
}
-
That's great thank you. The only slight drawnback I hadn't thought about is that it also disables the drag ordering of columns. Is there a way to still allow that do you think?wjp_bill– wjp_bill2020年04月03日 18:32:28 +00:00Commented Apr 3, 2020 at 18:32
-
Not sure why not working for you. M2.3.4 "drag ordering of columns" working well after applied this modification.Sohel Rana– Sohel Rana2020年04月04日 12:27:25 +00:00Commented Apr 4, 2020 at 12:27
-
Actually it's working ok now - I have no idea why! Thank you for your help, much appreciated.wjp_bill– wjp_bill2020年04月04日 14:51:54 +00:00Commented Apr 4, 2020 at 14:51
The accepted answer above caused some issues for me, as some column rows were missing after switching the "Columns" class to my custom implementation. Probably a conflict with another extension.
So instead I created a plugin for the "Columns" class and modified the "prepare" method:
di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Ui\Component\Listing\Columns">
<plugin name="vendor_module_plugin_magento_catalog_ui_component_listing_columns" type="Vendor\Module\Plugin\Magento\Catalog\Ui\Component\Listing\Columns" />
</type>
</config>
Columns.php
<?php
namespace Vendor\Module\Plugin\Magento\Catalog\Ui\Component\Listing;
class Columns
{
/**
* @param \Magento\Catalog\Ui\Component\Listing\Columns $subject
* @param \Closure $proceed
* @return \Closure
*/
public function aroundPrepare(\Magento\Catalog\Ui\Component\Listing\Columns $subject, \Closure $proceed)
{
// Try to get the config
$config = @$subject->getData('config');
if ($config) {
// Try to get a specific field that indicates that we are currently processing the product grid
$childDefaultsFieldActionProvider = @$config['childDefaults']['fieldAction']['provider'];
if ($childDefaultsFieldActionProvider === 'product_listing.product_listing.product_columns.actions') {
// Unset the "fieldAction", which removes the "link" on the product grid rows
if (isset($config['childDefaults']['fieldAction'])) {
unset($config['childDefaults']['fieldAction']);
// And save the updated config
$subject->setData('config', (array) $config);
}
}
}
return $proceed();
}
}