Problem/Motivation

Currently I don't think there's a convenient way to add cacheability metadata to the normalization via commerce product feeds events. I was thinking that might be convenient (eg. for stock or url cacheability). I've created a separate ticket to address getting cache contexts to actually work (#3229967: Support cache contexts) but I think just being able to add tags and max-age is already useful.

Proposed resolution

Make the normalization event support \Drupal\Core\Cache\RefinableCacheableDependencyInterface and pass the cacheability metadata along to the CacheableNormalization.

Remaining tasks

API changes

Drupal\commerce_product_feeds\Event\ProductVariationNormalizeEvent now implements RefinableCacheableDependencyInterface and its cacheability metadata will be passed onto the normalization.

CommentFileSizeAuthor
#3 3229969-3-do-not-test.patch2.43 KBandyf
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

AndyF created an issue. See original summary.

andyf’s picture

Assigned: andyf » Unassigned
Status: Active » Needs review
StatusFileSize
new2.43 KB

Here's a first go at that, feedback welcome, thanks! I've only done it for the variation normalization to keep the change small.

(Oh and I blindly followed the instructions for pushing changes when you've already got your own local branch, and I appear to have created a second branch on the issue fork, sorry about that! I've been working on return-variation-normalization-cacheability.)

Note I've also attached a patch for use with composer.json.

andyf’s picture

Assigned: Unassigned » andyf
Status: Needs review » Active

I think the test failures are down to #3229980: Fix FeedGenerationKernelTest.

andyf’s picture

Assigned: andyf » Unassigned
Status: Active » Needs review

Gah!

andyf’s picture

Issue summary: View changes
Status: Needs review » Fixed

  • AndyF committed f7682ec on 8.x-1.x
    Issue #3229969 by AndyF: Support custom cacheability metadata for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.