Magento 2
  • Personalization for Magento 2
  • Installing
  • Disconnecting
  • Uninstalling
  • Getting Started
  • Configuring
  • Hyvä Theme
  • Guides
    • Migrating to Magento2
    • Upgrading to >= 4.0.0
    • Varnish & Full-Page Caches
    • Advanced User Guide
    • Managing Blocks
    • Overriding or Extending Functionalities
      • Overriding Product Data
        • Excluding Products
        • Customising Pricing
        • Customising Categories
        • Resizing Images
      • Overriding Customer Data
    • Console Commands
    • Tagging Providers
  • Features
    • Product data caching
      • Built-in caching
      • Database caching
    • Variations (Configurable Products)
    • Add to Cart
    • Indexer
      • On 7.x
      • On 5.x and 6.x
      • On 4.x
      • On 3.x
    • Customer Group Pricing
    • Supplier Cost & Inventory Level
    • Restore Cart Link
    • Ratings & Reviews
    • Multi Currency (Exchange Rates)
    • Marketing permission and GDPR compatibility
    • Content Staging & Special Prices
  • Integrations
    • Using Yotpo
  • FAQ
  • Developing & Contributing
  • Visit Nosto
  • Issues
  • Releases
  • Addons
    • Multi Source Inventory (MSI)
      • Installing
      • Uninstalling
      • Configuring
    • Category Merchandising (CM 1.0)
      • Installing
      • Uninstalling
      • Configuring
      • Guides
        • Translating Frontend Strings
        • PWA Implementation
        • Using Elasticsearch
        • Segmentation
        • Overriding or Extending Functionalities
          • Customize Query Parameters
          • Customize Page Size Limit
          • Customize Exclude Filters
        • Debugging
Powered by GitBook
On this page

Was this helpful?

  1. Guides
  2. Overriding or Extending Functionalities
  3. Overriding Product Data

Customising Pricing

PreviousExcluding ProductsNextCustomising Categories

Last updated 3 years ago

Was this helpful?

If your store uses customized price handling or 3rd party module for product prices you might need to amend the custom price handling to Nosto module as well. Start by reading and .

Note: In order to use custom pricing in Nosto, you must amend the prices to Nosto's product model and handle the correct active variation. Please note that when using customized pricing you should disable the multi-currency method from the Nosto module's setting in Magento.

File app/code/My/Nosto/Observer/Product/Load.php

<?php

namespace My\Nosto\Observer\Product;

use Magento\Catalog\Model\Product;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Nosto\Tagging\Model\ElementFilter;

class Load implements ObserverInterface
{
    /**
     * IMPORTANT! You might need to inject additional services here in order to
     * get the custom prices for the product
     */
    public function __construct()
    {
    }

    /**
     * Observer for "nosto_product_load_after" event
     *
     * @param Observer $observer
     * @return void
     */
    public function execute(Observer $observer)
    {
        /* @var $product \Nosto\Object\Product\Product */
        $nostoProduct = $observer->getProduct();

        /* @var $product \Magento\Catalog\Model\Product */
        $observerData = $observer->getData();
        // Check that Magento product is set and get the custom prices from Magento product model
        if (!empty($observerData['magentoProduct']) && $observerData['magentoProduct'] instanceof Product) {
            $magentoProduct = $observerData['magentoProduct'];
            $nostoProduct->setPrice($magentoProduct->getCustomFinalPrice());
            $nostoProduct->setListPrice($magentoProduct->getCustomPrice());
        }
    }
}
how to extend Nosto module
how to alter Nosto product data