Issue
How do you rename the admin catalog Position label?
Solution
Magento\Catalog\Block\Adminhtml\Category\Tab\Product
class is responsible for generating this product's grid. We can rewrite the _prepareColumns
method in this class to make changes in the grid. Please follow the example below:
app/code/MilanDev/CustomBlock/etc/adminhtml/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">
<preference for="Magento\Catalog\Block\Adminhtml\Category\Tab\Product" type="MilanDev\CustomBlock\Block\Adminhtml\Category\Tab\Product"/>
</config>
app/code/MilanDev/CustomBlock/Block/Adminhtml/Category/Tab/Product.php
<?php
namespace MilanDev\CustomBlock\Block\Adminhtml\Category\Tab;
class Product extends \Magento\Catalog\Block\Adminhtml\Category\Tab\Product
{
/**
* @return $this
*/
protected function _prepareColumns()
{
parent::_prepareColumns();
$this->addColumn(
'position',
[
'header' => __('Your Text'),
'type' => 'number',
'index' => 'position',
'editable' => !$this->getCategory()->getProductsReadonly()
]
);
return $this;
}
}
Answered By - Milan Chandro Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.