0
<type name="Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Composite">
    <arguments>
        <argument name="modifiers" xsi:type="array">
            <item name="downloadablePanel" xsi:type="string">Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\DownloadablePanel</item>
            <item name="links" xsi:type="string">Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Links</item>
            <item name="samples" xsi:type="string">Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Samples</item>
            <item name="usedDefault" xsi:type="string">Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\UsedDefault</item>
        </argument>
    </arguments>
</type>

I want to remove below code from di.xml

    <item name="samples" xsi:type="string">Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Samples</item>

Can anyone help how to achieve this?

i want to remove below code from product edit page: enter image description here

  • I have not tried this but can you try xsi:type="null". Reference taken from - devdocs.magento.com/guides/v2.0/extension-dev-guide/build/… – Gagan Aug 9 '18 at 12:10
  • I have tried this already but not working – Rutvee Sojitra Aug 9 '18 at 12:11
  • If it does not work, it will be great if you share your requirement more, that way may be someone can help you with an alternative. – Gagan Aug 9 '18 at 12:11
  • @LAW i have added one image in question.please check if you can help – Rutvee Sojitra Aug 9 '18 at 12:16
3

Don't know if you can remove something, but you can make it do nothing.

Create your own class that looks like this:

<?php
namespace Vendor\Module\Ui;

class DummyProvider implements \Magento\Ui\DataProvider\Modifier\ModifierInterface
{
    public function modifyData(array $data)
    {
         return $data;
    }
    public function modifyMeta(array $meta)
    {
         return $meta;
    }
}

this class does nothing to the data or meta of the ui form.
Then replace what you want to remove with this class.
Add this in the di.xml of your module

<type name="Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Composite">
    <arguments>
        <argument name="modifiers" xsi:type="array">
            <item name="downloadablePanel" xsi:type="string">Vendor\Module\Ui\DummyProvider</item>
        </argument>
    </arguments>
</type>

This should cancel the effect of Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Samples.
I haven't tested the code though.

  • Yes it seems like the answer shared by sania and marius is the way out for this. – Gagan Aug 9 '18 at 12:58
  • It does not seem to work for me. New modifier is added but not replacing the existing item. I got it to work just using unset($meta['dowloadable']); in modifyMeta but it does not seem as efficient. – David Stone Mar 29 at 20:35
2

Let's say you want to change the links one. You have to create your own module that depends on the Magento_Downloadable module and add this in the di.xml of your module.

<type name="Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Composite">
    <arguments>
        <argument name="modifiers" xsi:type="array">
            <item name="links" xsi:type="string">Your\ClassName\Goes\Here</item>
        </argument>
    </arguments>
</type>

Just keep in mind that if the code you posted is from frontend/di.xml you have to add the new code in frontend/di.xml. Same goes for adminhtml/di.xml

  • Nope , i want to remove i don't want to customize it – Rutvee Sojitra Aug 9 '18 at 12:09
  • Yes it help me to reach at solution – Rutvee Sojitra Aug 9 '18 at 12:59
  • most welcome glade to help you – Rv Singh Aug 9 '18 at 12:59

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.