How to Remove Decimal From Quantity in Magento 2 Admin Product Grid

How to Remove Decimal From Quantity in Magento 2 Admin Product Grid

Magento 2 CMS offers grids in the admin panel for easy data management. It offers the Products, Customers, Orders, etc. grids to manage the data of products, customers, and orders.

Today, I’ll talk about the products grid, and particularly the product quantity column in the products grid.

The Products grid in Magento 2 displays product information like product ID, thumbnail, name, product type, attribute set, SKU, price, quantity, status, etc.

Now, in the default Magento 2 CMS, the product quantity is displayed in decimal format up to 4 decimals. For example, it shows 100.0000 quantity for products with 100 quantity.

The below image shows the default format of how the product quantity is displayed in the admin product grid in Magento 2:

How to Remove Decimal From Quantity in Magento 2 Admin Product Grid

However, in most cases, the product quantity is always in the whole number. The integer value of the product quantity does not make sense.

Therefore, you may want to remove this unnecessary format of quantity and simply display it as 100 in the products grid in the admin panel of Magento 2.

You can remove decimals from quantity in Magento 2 admin product grid using the below code.

Programmatic Method to Remove Decimal From Quantity in Magento 2 Admin Product Grid:

  1. Create product_listing.xml file at app/code/Vendor/Module/view/adminhtml/ui_component
  2. Create QtyColumn.php file at app/code/Vendor/Module/Ui/Component/Listing/Columns/

That’s it.

Once implemented, the product quantity will be displayed as shown below:

How to Remove Decimal From Quantity in Magento 2 Admin Product Grid

Use the above code and improve the product grid for simpler understanding!

Any doubts in the above method can be mentioned in the Comments section below. I’d be happy to help.

Also, do share the post with Magento Community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 10 Reviews)

He has been with Meetanshi for more than two years now as a Magento developer. A silent guy whom you can always find solving clients' issues, is an avid reader too.

Leave a reply:

Your email address will not be published.