Skip to content

Incorrect product price in PDP/PLP for customer group due to FPC still showing guest user's price #40474

@ioweb-gr

Description

@ioweb-gr

Preconditions and environment

  1. Magento 2.4.8‑p3
  2. Magento is running in production mode with full page cache (built-in FPC) enabled.

Steps to reproduce

  1. Configure a customer group to have a customer-group price for a product, then browse the product page as guest.
  2. Try to login as the user with the special customer group price and go back to the same page.
  3. Observe the rendered price before and after login with FPC enabled (log in via the standard Magento login and rely
    on FPC hits after the login redirect).

Expected result

The PDP/PLP prices should immediately switch to the logged-in customer group price after login, because FPC should vary by X-Magento-Vary and Magento\Framework\App\PageCache\Identifier should be used for cache lookup.

Actual result

PDP/PLP continue to show the guest price until the product is added to the cart (the customer group price only appears on the cart). Investigation shows

Magento\Framework\App\PageCache\IdentifierInterface preference points to

Magento\PageCache\Model\App\Request\Http\IdentifierForSave

(which relies on HttpContext and is empty when FPC hits), so the wrong cache key is used and the vary cookie isn’t read, causing cached guest prices to be served to logged-in users.

Additional information

We solved it by injecting the correct preference here in module-page-cache

Index: etc/di.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/etc/di.xml b/etc/di.xml
--- a/etc/di.xml
+++ b/etc/di.xml        (date 1769703123582)
@@ -44,5 +44,5 @@
     <preference for="Magento\PageCache\Model\VclGeneratorInterface" type="Magento\PageCache\Model\Varnish\VclGenerator"/>
     <preference for="Magento\PageCache\Model\VclTemplateLocatorInterface" type="Magento\PageCache\Model\Varnish\VclTemplateLocator"/>
     <preference for="Magento\PageCache\Model\Spi\PageCacheTagsPreprocessorInterface" type="Magento\PageCache\Model\PageCacheTagsPreprocessorComposite"/>
-    <preference for="Magento\Framework\App\PageCache\IdentifierInterface" type="Magento\PageCache\Model\App\Request\Http\IdentifierForSave"/>
+    <preference for="Magento\Framework\App\PageCache\IdentifierInterface" type="Magento\Framework\App\PageCache\Identifier"/>
 </config>

Previously

dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"

DI configuration for the class Magento\Framework\App\PageCache\IdentifierInterface in the GLOBAL area

Preference: Magento\PageCache\Model\App\Request\Http\IdentifierForSave

Constructor Parameters:
+-----------------------+----------------------------------------------------------------+------------------+
| Name                  | Requested Type                                                 | Configured Value |
+-----------------------+----------------------------------------------------------------+------------------+
| request               | Magento\Framework\App\Request\Http                             |                  |
| context               | Magento\Framework\App\Http\Context                             |                  |
| serializer            | Magento\Framework\Serialize\Serializer\Json                    |                  |
| identifierStoreReader | Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader |                  |
| identifier            | Magento\Framework\App\PageCache\Identifier                     |                  |
+-----------------------+----------------------------------------------------------------+------------------+

Plugins:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+

Plugins for the Preference:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+

After the patch

dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"

DI configuration for the class Magento\Framework\App\PageCache\IdentifierInterface in the GLOBAL area

Preference: Magento\Framework\App\PageCache\Identifier\Interceptor

Constructor Parameters:
+------------+---------------------------------------------+------------------+
| Name       | Requested Type                              | Configured Value |
+------------+---------------------------------------------+------------------+
| request    | Magento\Framework\App\Request\Http          |                  |
| context    | Magento\Framework\App\Http\Context          |                  |
| serializer | Magento\Framework\Serialize\Serializer\Json |                  |
+------------+---------------------------------------------+------------------+

Plugins:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+

Plugins for the Preference:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+

If you go back in previous versions you'll notice that it never showed IdentifierForSave and only was introduced later on which caused this error after we upgraded

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.8-p3Indicates original Magento version for the Issue report.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions