I want to remove Column Action from orders grid if order have certain status, how can I accomplish such behavior?
Or if it will be easier I would be happy if I could delete this View hyperlink :)
Thanks in advance :)
1 Answer 1
You can hide the View action for a particular order status using a plugin.
Create following files
app/code/Venodr/Module/etc/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\Sales\Ui\Component\Listing\Column\ViewAction">
<plugin name="order_grid_view_action" type="Vendor\Module\Plugin\Order\Grid\ViewAction" />
</type>
</config>
app/code/Vendor/Module/Plugin/Order/Grid/ViewAction.php
<?php
namespace Vendor\Module\Plugin\Order\Grid;
class ViewAction
{
public function afterPrepareDataSource(
\Magento\Sales\Ui\Component\Listing\Column\ViewAction $subject,
$result,
array $dataSource
) {
foreach ($result['data']['items'] as & $item) {
// add your condition here
if ($item['status'] != 'pending') {
$item['actions'] = null;
}
}
return $result;
}
}
-
Happy learning :)Dinesh Yadav– Dinesh Yadav2018年07月11日 13:28:15 +00:00Commented Jul 11, 2018 at 13:28
Explore related questions
See similar questions with these tags.