cancel
Showing results for 
Search instead for 
Did you mean: 

Disable qty column in the Product grid (adminhtml)

Disable qty column in the Product grid (adminhtml)

Hello,

 

there is description in vendor/magento/module-catalog-inventory/etc/adminhtml/di.xml file:

    <type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
        <arguments>
            <argument name="addFieldStrategies" xsi:type="array">
                <item name="qty" xsi:type="object">Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFieldToCollection</item>
            </argument>
            <argument name="addFilterStrategies" xsi:type="array">
                <item name="qty" xsi:type="object">Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection</item>
            </argument>
        </arguments>
    </type>

I wish to replace default "qty" column in Product Grid by my own. How can I disable or override this descriptors to prevent addition of the Catalog Inventory's "qty" column & filter to the grid?

 

Thanks,

Alex Gusev

1 REPLY 1

Re: Disable qty column in the Product grid (adminhtml)

I have used plugins to disable "qty" column:

 

namespace Venodr\Module\Plugin\CatalogInventory\Ui\DataProvider\Product;

use Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFieldToCollection as Subject;

class AddQuantityFieldToCollection {

    public function aroundAddField(Subject $subject, \Closure $proceed) {
        //$proceed(); - uncomment to enable column;
        return;
    }
}

 .../etc/di.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFieldToCollection">
        <plugin
                name="prxgt_wrhs_plugin"
                type="Vendor\Module\Plugin\CatalogInventory\Ui\DataProvider\Product\AddQuantityFieldToCollection"
                sortOrder="100"
                disabled="false"/>
    </type>
</config>