3
<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

4
  • 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
    Commented Aug 9, 2018 at 12:10
  • I have tried this already but not working Commented Aug 9, 2018 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
    Commented Aug 9, 2018 at 12:11
  • @LAW i have added one image in question.please check if you can help Commented Aug 9, 2018 at 12:16

2 Answers 2

4

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.

2
  • Yes it seems like the answer shared by sania and marius is the way out for this.
    – Gagan
    Commented Aug 9, 2018 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. Commented Mar 29, 2019 at 20:35
3

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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