0

Can we remove this tab in product edit view

i have override this file i have xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="roles-salable-qty" xsi:type="array">
                    <item name="class" xsi:type="string">YourVendor\YourModule\Ui\DataProvider\Product\Form\Modifier\SalableQuantity</item>
                    <item name="sortOrder" xsi:type="number">100</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
</config>

and i have file SalableQuantity

<?php

namespace YourVendor\YourModule\Ui\DataProvider\Product\Form\Modifier;


class SalableQuantity extends \Magento\InventorySalesAdminUi\Ui\DataProvider\Product\Form\Modifier\SalableQuantity
{
 
    public function modifyMeta(array $meta)
    {
      $numberCheck = 5;

            if ($numberCheck==5) {
                $meta['salable_quantity'] = [
                    'arguments' => [
                        'data' => [
                            'config' => [
                                'disabled' => true
                            ],
                        ],
                    ],
                ];
            }

        return $meta;
    }

   
}

I hope can someone help

1 Answer 1

2

The sort order of the SalableQuantity modifier is 300.
vendor/magento/module-inventory-sales-admin-ui/etc/adminhtml/di.xml

<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
    <arguments>
        <argument name="modifiers" xsi:type="array">
            <item name="salable_quantity" xsi:type="array">
                <item name="class" xsi:type="string">Magento\InventorySalesAdminUi\Ui\DataProvider\Product\Form\Modifier\SalableQuantity</item>
                <item name="sortOrder" xsi:type="number">300</item>
            </item>
        </argument>
    </arguments>
</virtualType>

To override the SalableQuantity modifier, you need to set the sort order value of your modifier to a higher value than the sort order of the SalableQuantity.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="roles-salable-qty" xsi:type="array">
                    <item name="class" xsi:type="string">YourVendor\YourModule\Ui\DataProvider\Product\Form\Modifier\SalableQuantity</item>
                    <item name="sortOrder" xsi:type="number">310</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
</config>

Recompile the code (bin/magento setup:di:compile) to see results.

Your Answer

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

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