1

Because of business logic I need to round all product prices to the nearest thousand.

Example:

If i have a price of $18600 i need to change the price to $19000. If i have $18400 i need to change it to $18000.

I've played with setDisplayValue($value) and getDisplayValue() methods from Magento_Framework/Pricing/Render/Amount.php but this does not change the price in all the store.

What file(s) should i modify to affect the behavior in all the store?

Thanks,

A. Martz.

3

I have modified a method convert of file Magento\Directory\Model\Currency.

declaring a plugin, file Vendor/Module/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\Directory\Model\Currency">
    <plugin name="vendor_module" type="Vendor\Module\Model\Plugin\Currency" />
</type>  

plugin model, file Vendor/Module/Model/Plugin/Currency.php

<?php
namespace Vendor\Module\Model\Plugin;
use Magento\Framework\Exception\InputException;

class Currency
{
    public function aroundConvert($subject, $proceed, $price, $toCurrency = null)
    {
        $price = $proceed($price, $toCurrency);     
        // you logic
        // warning ... logic affects the price of shipping  
        return $price;
    }
}

Also see Complete code on GitHub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.