1

I want to override getCustomizedOptionValue function in

Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn

In etc\adminhtml\di.xml:

 <preference for="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" type="XXX\ProductInfo\Block\Adminhtml\Items\Column\DefaultColumn" />

In block:

<?php

namespace XXX\ProductInfo\Block\Adminhtml\Items\Column;

    class DefaultColumn extends \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn
    {   
        public function getCustomizedOptionValue($optionInfo)
        {
            echo "dgggggggggggggfgd";exit;

        }
    }

Not working ..

If anything i want to do that..

Thanks.

1

Rather than extending block, You should use plugin for it.

your custom module di.xml as below:

<config>
    <type name="Magento\Sales\Block\Adminhtml\Items\Column\Name">
        <plugin name="DefaultColumnPlugin" type="XXX\ProductInfo\Plugin\Items\Column\DefaultColumn" sortOrder="1" disabled="false"/>
    </type>
</config>

Create a file DefaultColumn.php at location XXX\ProductInfo\Plugin\Items\Column

<?php

namespace XXX\ProductInfo\Plugin\Items\Column;

class DefaultColumn{

}

As per your requirement use Before, Around and After method.

0

This block also extended in another block Magento\Sales\Block\Adminhtml\Items\Column\Name.

so need to change

<preference for="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" type="XXX\ProductInfo\Block\Adminhtml\Items\Column\DefaultColumn" />

into

<preference for="Magento\Sales\Block\Adminhtml\Items\Column\Name" type="XXX\ProductInfo\Block\Adminhtml\Items\Column\DefaultColumn" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.