In Magento 2 Decimal comes from Database so if you want to remove from qty than you need to create column renderer. Please follow below step to create module.
Create Folder like app/code/Agtech/Qty and put below code into registration.php file
php
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Agtech_Qty', __DIR__);After that create composer.json file into above same path like registration.php and put code.css
{
"name": "agtech/module-qty",
"description": "Qty Decimal",
"type": "magento2-module",
"license": "GPL-3.0",
"authors": [
{
"name": "Agtech",
"email": "hello@akshargrouptechnologies.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Agtech\\Qty\\": ""
}
}
}Create etc/module.xml file into etc folder and add sequence tag followscode
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Agtech_Qty" setup_version="1.0.0">
<sequence>
<module name="Magento_CatalogInventory"/>
</sequence>
</module>
</config>
Create a renderer Agtech/Qty/Ui/Component/Listing/Columns/DecimalRemove.php and put below codephp
<?php
/**
* Created By : Nikul Prajapati
*/
namespace Agtech\Qty\Ui\Component\Listing\Columns;
class DecimalRemove extends \Magento\Ui\Component\Listing\Columns\Column
{
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items']))
{
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
{
if (isset($item[$fieldName]))
{
$item[$fieldName] = (int)$item[$fieldName];
}
}
}
return $dataSource;
}
}Create a renderer Agtech/Qty/view/adminhtml/ui_component/product_listing.xml
and put below codecode
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns">
<column name="qty" class="Agtech\Qty\Ui\Component\Listing\Columns\DecimalRemove">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="add_field" xsi:type="boolean">true</item>
<item name="label" xsi:type="string" translate="true">Quantity</item>
<item name="sortOrder" xsi:type="number">75</item>
</item>
</argument>
</column>
</columns>
</listing>
That's it. Now, You can remove decimal from quantity in product grid in Magento admin. If you face any problem while during so then Contact our Support Team.Share this playbook
