Using eventcatalog_product_get_final_price, setting the maximum price to be 100, if the price of a product is greater than 100 then it will set automatically to 100 and the product price is below 100 then it will be displayed that price. But that event is not working. below is code.


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="catalog_product_get_final_price">
        <observer name="marketing-rule" instance="Ahmad\MarketingPrice\Observer\ProcessFinalPriceObserver" />



namespace Ahmad\MarketingPrice\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer as EventObserver;

    class ProcessFinalPriceObserver implements ObserverInterface
        public function execute(\Magento\Framework\Event\Observer $observer)
                echo "test123";
                $product = $observer->getEvent()->getProduct();
                $pId = $product->getId();
                $storeId = $product->getStoreId();
                $finalPrice = 100;
                $product->setFinalPrice($finalPrice); // set final price here 
                return $this;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.