PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How do you rename the admin catalog Position label?

 August 23, 2022     magento2     No comments   

Issue

How do you rename the admin catalog Position label?

enter image description here


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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing