{"id":1794,"date":"2021-05-31T10:26:45","date_gmt":"2021-05-31T10:26:45","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/remove-decimal-from-quantity-in-magento-2-admin-product-grid\/"},"modified":"2025-07-16T17:44:44","modified_gmt":"2025-07-16T12:14:44","slug":"remove-decimal-from-quantity-in-magento-2-admin-product-grid","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/remove-decimal-from-quantity-in-magento-2-admin-product-grid\/","title":{"rendered":"How to Remove Decimal From Quantity in Magento 2 Admin Product Grid"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2\u00a0CMS 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Today, I\u2019ll talk about the products grid, and particularly the product quantity column in the products grid.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/catalog\/introduction\" target=\"_blank\" rel=\"noreferrer noopener\">Products grid in Magento 2<\/a>&nbsp;displays product information like product ID, thumbnail, name, product type, attribute set, SKU, price, quantity, status, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The below image shows the default format of how the product quantity is displayed in the admin product grid in Magento 2:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/05\/vefore-decimal-1024x446.png\" alt=\"How to Remove Decimal From Quantity in Magento 2 Admin Product Grid\" class=\"wp-image-15197\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">However, in most cases, the product quantity is always in the whole number. The integer value of the product quantity makes little sense.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, you may want to remove this unnecessary format of quantity and simply display it as 100 on the products grid in the admin panel of Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can&nbsp;<em><strong>remove decimals from quantity in Magento 2 admin product grid<\/strong><\/em>&nbsp;using the below code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Programmatic Method to Remove Decimal From Quantity in Magento 2 Admin Product Grid:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<strong>product_listing.xml<\/strong>&nbsp;file at<strong>&nbsp;app\/code\/Vendor\/Module\/view\/adminhtml\/ui_component<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;listing xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd\">\n    &lt;columns name=\"product_columns\" class=\"Magento\\Catalog\\Ui\\Component\\Listing\\Columns\">\n        &lt;column name=\"qty\" class=\"Vendor\\Module\\Ui\\Component\\Listing\\Columns\\QtyColumn\">\n            &lt;argument name=\"data\" xsi:type=\"array\">\n                &lt;item name=\"config\" xsi:type=\"array\">\n                    &lt;item name=\"filter\" xsi:type=\"string\">textRange&lt;\/item>\n                    &lt;item name=\"add_field\" xsi:type=\"boolean\">true&lt;\/item>\n                    &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Quantity&lt;\/item>\n                    &lt;item name=\"sortOrder\" xsi:type=\"number\">75&lt;\/item>\n                &lt;\/item>\n            &lt;\/argument>\n        &lt;\/column>\n    &lt;\/columns>\n&lt;\/listing><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>QtyColumn.php<\/strong>&nbsp;file at&nbsp;<strong><strong>app\/code\/Vendor\/Module\/Ui\/Component\/Listing\/Columns\/<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Vendor\\Module\\Ui\\Component\\Listing\\Columns;\n\nuse Magento\\Ui\\Component\\Listing\\Columns\\Column;\n\nclass QtyColumn extends Column\n{\n    const NAME = 'column.qty';\n\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource['data']['items'])) {\n            $fieldName = $this->getData('name');\n            foreach ($dataSource['data']['items'] as &amp; $item) {\n                if (isset($item[$fieldName])) {\n                    $item[$fieldName] = (int)$item[$fieldName];\n                }\n            }\n        }\n        return $dataSource;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once implemented, the product quantity will be displayed as shown below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/05\/Screenshot-at-May-26th-2021-11.45.49-am-1024x429.png\" alt=\"How to Remove Decimal From Quantity in Magento 2 Admin Product Grid\" class=\"wp-image-15195\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Use the above code and improve the product grid for a simpler understanding!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also read:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/meetanshi.com\/blog\/get-product-stock-information-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Get Product Stock Information in Magento 2<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/meetanshi.com\/blog\/update-column-datatype-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Update Column Datatype in Magento 2<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2\u00a0CMS 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\u2019ll talk about the products grid, and particularly the product quantity column in the products grid. The&nbsp;Products grid in Magento 2&nbsp;displays product information like product [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1794","post","type-post","status-publish","format-standard","hentry","category-magento"],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1794"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1794\/revisions"}],"predecessor-version":[{"id":18060,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1794\/revisions\/18060"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}