0

I am trying to get all currency conversions to round up to the nearest dollar, which I have successfully done by hacking the core Currency.php file (/app/code/core/Mage/Directory/Model/Currency.php). I know this is not a good long term solution, but I can't seem to get a proper local extender going. Any suggestions are greatly appreciated. Thanks.

Magento 1.9.1

Here's what I have:

app/code/local/CEM/Currencyround/controllers/RoundCurrency.php

            <?php

            class CEM_Currencyround_RoundCurrency extends Mage_Directory_Model_Currency {
              public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)
                {
                /**
                 * CHANGE BELOW FOR CEMPEPTIDES ROUNDING DECIMALS UP "ceil()"
                 * */
                    return $this->formatPrecision(ceil($price), 2, $options, $includeContainer, $addBrackets);
                }
            }

app/code/local/CEM/Currencyround/etc/config.xml

            <?xml version="1.0"?>
            <config>
              <modules>
                <CEM_Currencyround>
                  <version>1</version>
                </CEM_Currencyround>
              </modules>
             <frontend>
                    <routers>
                        <CEM_Currencyround>
                            <use>standard</use>
                            <args>
                                <module>CEM_Currencyround</module>
                                <frontName>CEM_Currencyround</frontName>
                            </args>
                        </CEM_Currencyround>
                    </routers>
                </frontend>
            </config>

app/etc/modules/CEM_Currencyround.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <config>
              <modules>
                <CEM_Currencyround>
                  <version>1</version>
                  <active>true</active>
                  <codePool>local</codePool>
                </CEM_Currencyround>
              </modules>
            </config>
1

You are trying to override a model not a controller.
You can override model using below code.

app/code/local/CEM/Currencyround/etc/config.xml

<config>
    ------
    <global>
        --------
        <models>
            <directory>
                <rewrite>
                    <currency>CEM_Currencyround_Model_RoundCurrency</currency>
                </rewrite>
            </directory>
        </models>
        --------
    </global>
    -------
</config>


app/code/local/CEM/Currencyround/Model/RoundCurrency.php

class CEM_Currencyround_Model_RoundCurrency extends Mage_Directory_Model_Currency {
// your overridden method
             }



Some useful links :

  • Thanks so much. I clearly have to learn a lot about the magento structure. Thanks also for the links! – Rich D Jul 15 '15 at 12:59

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.