AW Catalog Permissions + Cache Warmup Results in Incorrect Pricing
Symptom
When using the AW Catalog Permissions module, and requesting separate cache copies for each customer group (as shown below), the pages are properly cached during regular visits, but are not properly warmed-up.
After the warmup runs, logged-in users should see products with special pricing information tailored to their Customer Group. Instead, they are being served blank pages, or pages that show incorrect pricing for their group.
Essentially, the logged-in members of customer groups are being treated as if they are not logged in. Private products appear blank (because non-logged-in users would not be allowed to see them) and public products are displayed with the wrong pricing (because non-logged-in users would not have access to the special prices).
Cause
There are two modules that control the cache warmup by customer group: LiteMage and AW Catalog Permissions. LiteMage initializes the user and customer group settings for the warmup. AW Catalog Permissions determines what products and prices the warmup user is allowed to view.
The order that these two modules are loaded is important.
Both modules listen for event controller_action_predispatch
like so:
<controller_action_predispatch> <observers> <front_controller_predispatch> <type>singleton</type> <class>catalogpermissions/observer</class> <method>controllerActionPredispatch</method> </front_controller_predispatch> </observers> </controller_action_predispatch>
Ideally, LiteMage would perform its initialization tasks first, and then AW Catalog Permissions would cache the catalog IDs according to LiteMage’s user and group settings. Magento, however, loads modules alphabetically by name, which means AW loads before Litespeed.
This is a problem. Without LiteMage’s user and group settings, AW Catalog Permissions defaults to the non-logged-in user settings and caches the catalog IDs without the special permissions of the customer group. By the time LiteMage sets the correct customer group, it’s already too late.
Later, when it’s time to serve from the cache, AW Catalog Permissions will only use its preloaded cached version, so LiteMage’s set user and customer group will have no effect then, either.
Note: The reason why this only happens with the cache warmup and not with regular site visitors is because the warmup is triggered by the cron. In the absence of a real user, LiteMage must simulate one, and it’s the simulation step that must be loaded before AW Catalog Permissions is loaded. In the case of a real user visit, no simulation step is necessary. The actual customer group is already defined in advance of the AW module, and everything works as expected.
Solution
Because modules are loaded alphabetically, the best way to fix this is to simply rename the AW Catalog Permissions configuration file to make it come after LiteMage. Add the prefix “ZZZ_
” like so:
[~/public_html/app/etc/modules]# mv AW_Catalogpermissions.xml ZZZ_AW_Catalogpermissions.xml
The LiteSpeed module will now be loaded before the ZZZ_AW module, thereby resolving this issue.