1

I have created custom module to override this (Magento/Framework/Data/Structure) file.

I have tried this in di.xml file:

<preference for="Magento/Framework/Data/Structure" type="Modulename\Extendfiles\Block\Structure" />
<preference for="Magento/Framework/Data/Structure" type="Modulename\Extendfiles\Data\Structure" />
<preference for="magento/framework/Data/Structure" type="Modulename\Extendfiles\Data\Structure" />

But it doesn't work, can anyone help me to override this file?

  • Have you tried to flush magento cache? – Kyrylo Romantsov Nov 2 '17 at 11:20
  • 1
    why Magento/Framework/Data/Structure you have multiple preference for Magento/Framework/Data/Structure for same class – Amit Bera Nov 2 '17 at 11:24
  • I have try one by one with preference – Jimit Bhavsar Nov 2 '17 at 12:04
  • namespace Modulename\Extendfiles\Data; class Structure extends \Magento\Framework\Data\Structure { } – Jimit Bhavsar Nov 2 '17 at 12:15
0

Try these CLI commands after you modify your di.xml:

php bin/magento setup:di:compile
php bin/magento cache:flush

These commands must be executed in the root of your magento2 project.

Also choose only one preference. (Amit Bera's advise)

So, add this code instead of your:

<preference for="Magento\Framework\Data\Structure" type="Modulename\Extendfiles\Data\Structure" />
  • namespace Modulename\Extendfiles\Data; class Structure extends \Magento\Framework\Data\Structure { } – Jimit Bhavsar Nov 2 '17 at 12:17
  • @Kyrylo, I have tried as you said but no luck – Jaisa Jan 23 at 10:23

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.