In my custom product type model, I have:

public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode) {
    return parent::prepareForCartAdvanced($buyRequest, $product, $processMode);

In my product type's price model, I have:

public function getPrice($product) {
    // This displays 500
    echo $product->getMyProperty();
    // This does not return 500 - the product's price in cart is 0.00
    return $product->getMyProperty();
    // This does return 500 - the product's price in cart is 500.00
    return 500;

Why can I not return $product->getMyProperty() even though the value I have set is properly echoed?

No matter what I do, I am only able to set the return price if I key a number in directly. I cannot set any value in the price model based on something passed through $product.

1 Answer 1


Suggesting to you create Custom attribute of type price name as my_property from Backend as getPrice() is always return a numeric value.

Also, don't use prepareForCartAdvanced() for this case.If want to change the price of product basic of an attribute then

use magento event/observer. Basically there are two events,by which you can change the cart price of that products:

  1. checkout_cart_product_add_after
  2. checkout_cart_update_items_after
  3. checkout_cart_product_update_after

As per as magento system, a cart item price change using setter functions setCustomPrice(), setOriginalCustomPrice of cart item Object.

Just like:

// Enable super mode on the product.

An example: Custom options operations

  • The reason I have a custom product type in the first place is because a price attribute cannot be used (decimal precision is not sufficient). Why do I need to use an observer to set the price of a custom product type? Isn't that precisely what a custom price model is for?
    – pspahn
    Jun 2, 2015 at 16:05
  • You could enhance the decimal precision of prices throughout your DB. It is a painful process (trust me, I've done it), and you'd have to override lots of Magento models to get it working, but it's feasible. Oct 19, 2015 at 13:44

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.