We want to display customer specific prices on all product listings and product pages on the front end.

So far what we've done is created a collection plugin for the resource model which fetches a price based on the customers id.

namespace Vendor\Module\Plugin\Catalog\Model\ResourceModel\Product;

// some imports

class CollectionPlugin
    protected $_customerSession;
    protected $_customerFactory;
    protected $_productPriceFactory;
    protected $_objectManager;
    protected $_storeManager;

    public function __construct(
        CustomerFactory $customerFactory,
        ProductPriceFactory $productPriceFactory,
        StoreManagerInterface $storeManager,
        Session $customerSession
    ) {
        $this->_customerFactory = $customerFactory;
        $this->_productPriceFactory = $productPriceFactory;
        $this->_customerSession = $customerSession;
        $this->_storeManager = $storeManager;

    public function afterLoad(Collection $subject, $result, $printQuery = false,     $logQuery = false)
        $items = $subject->getData();
        return $result;

    private function fetchCustomerPrice($items) {
        // some code


This works fine, however now we are stuck with the problem of caching. The price for the customer who visits a product page first gets shown to everyone.

We've tried following the instructions here: How Magento manages store-wise cache. For our purposes we use customer id instead of zip code. The PageCache Identifier plugin seems to work or at least it's run each time the page loads regardless of caching. Identity plugin does not work as its value gets cached the same way product prices do.

We think that the problem lies with the block and/or model cache, but we are not sure.

How should we continue?

  • Customer wise OR Customer_Group ?
    – Ravi Soni
    Commented Dec 19, 2019 at 9:00
  • Customer wise, @Ravi Soni
    – MikeGrove
    Commented Dec 19, 2019 at 9:53

1 Answer 1


Try to use ajax calls, it is not cached. Other way you may not be able to do it. Just call some route using ajax and update prices. Use custom cache (with customer id or something) to store those customer specific prices (or do not if not need, do as you required. You can take those prices later in some other places, so won't need to check DB or API every time). When adding to cart, use observer checkout_cart_product_add_after and update customPrices with customer specific price (setCustomPrice, setOriginalCustomPrice). And it will add with your customer specific price.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.