3

I have successfully override Mage_Catalog_Model_Product_Type_Price to edit the getPrice function with this code.

class Myc_Mymodule_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
{

    public function getPrice($product)
    {
        return 10;
    }

This works for simple and grouped product, but it's not work for Configurable and Downloadable Product.

But if I edit getPrice function directly in the core file app/code/core/Mage/Catalog/Model/Product/Type/Price.php with the above code, it works for all product.

How this can happen? And how to make it works for all product by overiding Mage_Catalog_Model_Product_Type_Price?

4

The problem is, that this model is only used for grouped and simple products. For configurables another model is used:

class Mage_Catalog_Model_Product_Type_Configurable_Price extends Mage_Catalog_Model_Product_Type_Price

And it extends from Mage_Catalog_Model_Product_Type_Price therefore your change works, if you edit the core file.

I answered here a question how to use an observer to change the price, maybe this helps you: How to create product price in real time based on forms?

  • Thanks Fabian, you help me again. I think you know what I want based on my previous question you answered :D – Wakanina Mar 1 '13 at 6:22

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.