Hello,
i changed the RouncPrices() Function. So my Price is rounding to the next higher 5 or 10 value.
10,42 € -> 10,45 €
10,47 € -> 10,50 €
The only Problem is that the Price isnt round on the Detailsite of the articles...
Where should i edit ?
Hello @christian _stegemann
You can copy app/code/core/Mage/Core/Model/Store.php to app/code/local/Mage/Core/Model/Store.php. By doing this you protect this file from being overwritten during upgrades. Next change the following code in that file from:
/** * Round price * * @param mixed $price * @return double */ public function roundPrice($price) { return round($price, 2); }
Here is this function you can check price and convert according to your business logic.
Hello @christian _stegemann,
You can copy app/code/core/Mage/Core/Model/Store.php to app/code/local/Mage/Core/Model/Store.php and change below method in it.
/** * Round price * * @param mixed $price * @return double */ public function roundPrice($price) { return ceil($value / 5) * 5; }
Let me know if you have any issue.
--
If my answer is useful, please Accept as Solution & give Kudos
Thank you both for your answer.
1) I already changed the code in "app/code/core/Mage/Core/Model/Store.php":
2) I tried to copy this file to "local", but i don't have the same File Structure there ...
Now the Prices are still rounded, but on the Detailview of an article, this "Rounding" doesn't work....
Is there any customization you have done on detail page.
I don't know exactly if someone made some changes in the past... But where do i check the detailsite?
All other sites work with the new rounding as they should (Paypal not testet atm).
You can check in below folder files:
app/design/frontend/rwd/default/template/catalog/product
price.phtml
View.phtml
app/code/core/catalog
app/code/local/catalog
The old Price with the class "old-price" is rounded. The problem is located in the Special Price with the class "special-price".
Maybe this will help you to help me
Hello @christian _stegemann
Just observe catalog_product_load_after event, and overwrite special_price with a rounded value.
Create a bootstrap file for your module:
app/etc/modules/Danslo_RoundSpecialPrice.xml:
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Danslo_RoundSpecialPrice> <active>true</active> <codePool>local</codePool> <depends> <Mage_Catalog /> </depends> </Danslo_RoundSpecialPrice> </modules> </config>
Specify that we want to observe the product load event:
app/code/local/Danslo/RoundSpecialPrice/etc/config.xml:
<?xml version="1.0" encoding="UTF-8"?> <config> <global> <models> <roundspecialprice> <class>Danslo_RoundSpecialPrice_Model</class> </roundspecialprice> </models> <events> <catalog_product_load_after> <observers> <round_special_price> <class>roundspecialprice/observer</class> <type>singleton</type> <method>roundSpecialPrice</method> </round_special_price> </observers> </catalog_product_load_after> <catalog_product_collection_load_after> <observers> <round_special_price> <class>roundspecialprice/observer</class> <type>singleton</type> <method>roundSpecialPriceInCollection</method> </round_special_price> </observers> </catalog_product_collection_load_after> </events> </global> </config>
Then just write your observer implementation:
app/code/local/Danslo/RoundSpecialPrice/Model/Observer.php:
class Danslo_RoundSpecialPrice_Model_Observer { public function roundSpecialPrice($observer) { $product = $observer->getProduct(); if ($product->getSpecialPrice()) { $product->setSpecialPrice(round($product->getSpecialPrice())); } } public function roundSpecialPriceInCollection($observer) { foreach ($observer->getCollection() as $product) { if ($product->getSpecialPrice()) { $product->setSpecialPrice(round($product->getSpecialPrice())); } } } }
Thank you for your answer. I created these files, but the prices not changed...
It seems that the new class didnt get implemented. Where should the system use the class?