I have created column name sku in custom grid.
Set href for sku values.
If i click the sku link,it does not go to desire page.
It go to desire page when i press right click and open the link in new tab.
In layout:
<column name="product_sku" class="Xxx\Stock\Ui\Component\Listing\Columns\Product">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Sku</item>
</item>
</argument>
</column>
In Product file:
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$fieldName])) {
$productId = $this->_product->getIdBySku($item[$fieldName]);
$html = "<a href='" . $this->context->getUrl('catalog/product/edit', ['id' => $productId]) . "' >";
$html .= $item[$fieldName];
$html .= "</a>";
$item[$fieldName] = $html;
}
}
}
return $dataSource;
}