I am wondering if anyone can offer advice on the best/easiest way to accomplish the following:

I would like to be able to change the price of a product based on a URL parameter. So for example if the regular price of a product is $100, I would like to be able to specify some sort of URL parameter that would allow me to have the price of the product be a lower amount.

I am currently considering creating coupon codes and auto applying them using the linksture extension and then having some logic lookup what the discount is and then apply it on the product page. I think this will accomplish the goal, but wondering if there is a better/simpler/cleaner way.


This blog post (German) gives an example for dynamic pricing: http://www.avs-webentwicklung.de/nc/blog/artikel/magento-umsetzung-von-flexiblen-preisen.html

Summary, adjusted for your requirements:

  1. Add a hidden input field to the form on the product page that you fill based on the URL parameter, let's call it custom_discount.
  2. Create a custom module with an observer for catalog_product_get_final_price:

  3. In the observer, set the final price based on the request:

     * Update price for product items
     * @param Varien_Event_Observer $observer
    public function getFinalPrice($observer) {
        /* @var Mage_Catalog_Model_Product $product */
        $product = $observer->getEvent()->getProduct();
        if ($buyRequest = $product->getCustomOption('info_buyRequest')) {
            $buyRequest = unserialize($buyRequest->getValue());
            if (is_array($buyRequest) && isset($buyRequest['custom_discount'])) {

Additional changes:

On the product page itself (in the product view template), you can use $_product->setFinalPrice(YOUR_LOGIC_BASED_ON_PARAMETER($this->getRequest()->getParam('YOUR_PARAMETER')); to change the displayed price as well.

YOUR_LOGIC_BASED_ON_PARAMETER() could be a helper method in your custom module.

Note that this changes the product price dynamically, so that it will show up with this price as normal price in cart and order. No explicit discount will be shown.

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.