I have checked Magento 2.2.3 by default showing up 4 decimal places on selling price in catalog product grid and frontend side layered navigation except for price attribute other than showing up 4 decimal places. Is that magento2 default issues?
If you like my question is useful then kudos on it.
Hello @kamlesh_solanki1
By default Magento 2 showing two digits.
Maybe you are using other locale and it will use 4 digit, may i know your locale?
Price showing up correct but other attribute created based on price like the special price they will display 4 decimal places in product grid admin backend
override the Ui/Component/Listing/Columns/product_listing.xml
add this code
<column name="price" class="Magento\Catalog\Ui\Component\Listing\Columns\Price" sortOrder="70">
<settings>
<addField>true</addField>
<filter>textRange</filter>
<label translate="true">Price</label>
</settings>
</column>
<column name="special_price" class="Magento\Catalog\Ui\Component\Listing\Columns\Price" sortOrder="74">
<settings>
<addField>true</addField>
<filter>textRange</filter>
<label translate="true">Special Price</label>
</settings>
</column>
<column name="weight" class="Magento\Catalog\Ui\Component\Listing\Columns\Weight" sortOrder="76">
<settings>
<addField>true</addField>
<filter>textRange</filter>
<label translate="true">Weight</label>
</settings>
</column>
<column name="qty" class="Magento\Catalog\Ui\Component\Listing\Columns\Qty" sortOrder="78">
<settings>
<addField>true</addField>
<filter>textRange</filter>
<label translate="true">Qty</label>
</settings>
</column>Create the module-catalog/Ui/Component/Listing/Columns/Qty.php file
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$store = $this->storeManager->getStore(
$this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
);
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$fieldName])) {
$item[$fieldName] = intval($item[$fieldName]);
}
}
}
return $dataSource;
}Create the module-catalog/Ui/Component/Listing/Columns/weight.php
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$store = $this->storeManager->getStore(
$this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
);
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$fieldName])) {
$item[$fieldName] = number_format($item[$fieldName], 2);
}
}
}
return $dataSource;
}