I want to show custom price on product detail page. Based on category id

suppose when I view product A with price 100 and categeory id 1

I want to show its price as 100 + 20

and for category id 2

price as 100

What observer should I use to show different price without changing code?


you can use catalog_product_load_after event to change price in product detail page


In observer.php,

 public function loadaftercatalog($observer)
        $oldprice = 0;
        $product = $observer->getEvent()->getProduct();
        $oldprice = $product->getPrice();
        $newprice = 20 + $oldprice;
        $categoryIds = $product->getCategoryIds();
        foreach($categoryIds as $categoryId){
                if($categoryId == 5){
        return $this;
  • Nothing change using this . – Pratik Kamani Aug 4 '16 at 11:20

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.