0

When I programmatically update a product, all cached products (varnish) seem to be cleared. This is the header from the purge request:

ReqHeader      X-Magento-Tags-Pattern: ((^|,)cat_p_3478(,|$))|((^|,)cat_p(,|$))

I think it's the cat_p tag that causes the clearing, but I don't understand why all pages tagged with this tag need to be cleared. This simple code triggers the purge request:

$product = $productRepository->get($data->sku);
$product->setStoreId(0);
$product->save();

What can I do to fix this?

0

I think I found the solution, I had the areacode set to 'frontend'. So I changed

$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');

to

$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('webapi_rest');

This removes the cat_p tag from the purge request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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