0

I have below code in my 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/Ui/Model/Export/ConvertToCsv" type="Abc/CustomChanges/Model/ConvertToCsv" />
</config>

In my ConvertToCsv class

    <?php

    namespace Abc\CustomChanges\Model;

    /**
     * Class ConvertToCsv
     */

    class ConvertToCsv extends \Magento\Ui\Model\Export\ConvertToCsv
    {

      public function getCsvFile()
      {
         echo 'qqq'; exit;
      }
    }

I have enabled the module and try to export order csv. it should echo and exit but it is not.

  • Try below answer and guess that should be problem in your case @stackuser – Prathap Gunasekaran Apr 3 '19 at 9:18
  • sorry which answer? – Stack user Apr 3 '19 at 9:18
1

Replace your preference element with this,

<preference for="Magento\Ui\Model\Export\ConvertToCsv" type="Abc\CustomChanges\Model\ConvertToCsv" />

It seems you've missed Model instead you've given as Mode and also you've used forward slash instead of backslash.

Hope it resolves.

  • Thanks I missed that but after update still not working – Stack user Apr 3 '19 at 9:27
  • clean cache and check and do update file paths as well – Prathap Gunasekaran Apr 3 '19 at 9:27
  • I have done everything cache:clean, upgrade, dicompile but no luck. I have changed <preference to <preferencewew to generate error and error generated that means di.xml is calling but not woking – Stack user Apr 3 '19 at 9:37
  • filepaths are also correct – Stack user Apr 3 '19 at 9:40
  • 1
    Thank you! it resolved! – Stack user Apr 3 '19 at 9:48
0

I am facing the same issue. But still unable to override this. My code is as below.

<?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\Ui\Model\Export\ConvertToCsv" type="Muniwar\AdvanceExport\Model\Export\ConvertToCsv2" /> </config>

namespace Muniwar\AdvanceExport\Model\Export;
class ConvertToCsv2 extends \Magento\Ui\Model\Export
{
    public function getCsvFile()
    {
        echo 'qqq'; exit;
    }

}

`

  • Welcome @priyanka-bhartiya to Magento Stack Exchange. If you have a new question, please click on Ask Question button to ask yours. Please don't post your problem as the answer. – Mohit Kumar Arora Jun 28 '19 at 10:40

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.