1

How i can round rule_price from table catalogrule_product_price ?

i try to change calcPriceRule from Mage_CatalogRule_Helper_Data, no results!

have you an idea of what function save rule_price in catalogrule_product_price ?

Thanx

2
  • What would be the rounding rule? Nearest dollar, quarter, etc? Do you have any core edits to the code or extensions that interact/override with the Catalog Price rules?
    – kab8609
    Commented May 25, 2014 at 17:59
  • I want to round to the nearest dollar for catalog price rules. I have any core edits and no extension for catalog rules.
    – Flo69
    Commented May 25, 2014 at 18:05

2 Answers 2

2

I think the easiest would be to hook into the event catalog_product_get_final_price and just round the price to the amount you want.

How to implement observers

Is there anywhere on Magento.stackexchange a great answer how to implement an observer I can link to for the future? To lazy to write it down all the time, please add the link to the comments

2
  • Your methods can actually work, but is not recommended by Magento I think! You change the rendering of the front without changing the values ​​in the database. If I change the functions on the event catalog_product_get_final_price, i change only render! I want to change the value when it is saved or calculated. Do you understand the difference between ?
    – Flo69
    Commented May 26, 2014 at 16:33
  • Did you try this? I'm quite sure, that the method is called before the price is copied to the quote item? Commented May 26, 2014 at 20:58
1

You can see this Mage_CatalogRule_Model_Observer, function processFrontFinalPrice it's called when get final price, so you can change something in this.

if (!isset($this->_rulePrices[$key])) {
    $rulePrice = Mage::getResourceModel('catalogrule/rule')
        ->getRulePrice($date, $wId, $gId, $pId);
    $this->_rulePrices[$key] = $rulePrice;
} 

By override model observer.

Some articles, maybe relate to

3
  • Your methods can actually work, but is not recommended by Magento I think! You change the rendering of the front without changing the values ​​in the database. If I change the functions on the event catalog_product_get_final_price, i change only render! I want to change the value when it is saved or calculated. Do you understand the difference between ?
    – Flo69
    Commented May 26, 2014 at 16:33
  • Mage::getResourceModel('catalogrule/rule') get data from data via getRulePrice, so you can check if you want round something.
    – user7804
    Commented May 27, 2014 at 9:36
  • 1
    If you like when update to database you can check Mage_CatalogRule_Model_Action_Index_Refresh class, it's used for calculation before saving to database
    – user7804
    Commented May 27, 2014 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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