Magento – Show Different Product Price Using Observer

priceproduct

on product detail page i want to show price other than original price via observer.

Say product with price 100 will show price as 120 or 110

which observer should i use to do same

I found product price comes from catalog/product/price.phtml

is there any way in admin > catalog > category > custom deign

to call my custom price.html for specifi category

something like below

<reference name="product.info">
            <action method="setTemplate"><template>catalog/product/view_mour.phtml</template></action>
</reference>

Update code:

<?xml version="1.0"?>
<config>
  <modules>
    <Mour_Customgroup>
      <version>0.1.0</version>
    </Mour_Customgroup>
  </modules>
  <frontend>
    <events>
         <catalog_product_load_after>
            <observers>
                <setadiscountprice>
                    <type>singleton</type>
                    <class>Mour_Customgroup_Model_Observer</class>
                    <method>changeprice</method>
                </setadiscountprice>
            </observers>
          <catalog_product_load_after>
    </events>
  </frontend>
</config> 

and observer.php

<?php
class Mour_Customgroup_Model_Observer
{

    public function changeprice(Varien_Event_Observer $event) {
    if($_GET['id']){
        $pricetoadd=Mage::getModel('catalog/product')->load($_GET['id'])->getPrice(); // error comes after adding this line

        $product = $event->getEvent()->getProduct();
        $originalprice = $product->getPrice();
        $customprice = $originalprice+$pricetoadd;
        $product->setPrice($customprice);
    }
   }
}

i am trying to add price of product (id from get parameter) to product price

if i remove this line : $pricetoadd=Mage::getModel('catalog/product')->load($_GET['id'])->getPrice();

it works fine

Best Answer

you can use catalog_product_load_after event to change the product price in view page.

  <catalog_product_load_after>
            <observers>
                <custom_checkout_observer>
                    <type>singleton</type>
                    <class>Custom_Custom_Model_Observer</class>
                    <method>loadaftercatalog</method>
                </custom_checkout_observer>
            </observers>
    </catalog_product_load_after>

public function loadaftercatalog($event) {
    $product = $event->getEvent()->getProduct();
    $originalprice = $product->getPrice();
    $customprice = $originalprice+20;
    $product->setPrice($customprice);
   }

}
Related Topic