Block is incorrectly cached under some circumstances

Created on 8 December 2021, almost 3 years ago
Updated 2 March 2024, 7 months ago

Hi,

Many thanks for this module!

Problem/Motivation

The block is cached on a time basis rather than a product or url basis, this means the same product list is presented for every product on a site until the cache clears, at which point a new set of products is presented for every product viewed.

Steps to reproduce

  • Create a Block at /admin/structure/block
  • Add this block to a template using eg twig tweak {{ drupal_entity('block', 'customersalsobought') }}
  • View a product and note the products shown in the block
  • View a different product that should show different Also Bought products.
  • The product list will be the same on both Products viewed

Proposed resolution

Add per url caching

Remaining tasks

Decide if this is the best approach.

User interface changes

None

API changes

None

Data model changes

None

Note:
I also

  • added Tags for commerce_product_list so the block will be updated should items be added/removed/updated on the site.
  • shifted the MaxAge cache to a function so it was consistent with the other cache functions I created.

fork/patch to follow

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇳🇿New Zealand AndyD328 Lyttelton, NZ 🇳🇿

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024