Skip to content
Snippets Groups Projects
Commit cde3bc8d authored by Andy Dopleach's avatar Andy Dopleach Committed by Goran Nikolovski
Browse files

Issue #3253200 by AndyD328, nsalves, gnikolovski: Block is incorrectly cached...

Issue #3253200 by AndyD328, nsalves, gnikolovski: Block is incorrectly cached under some circumstances
parent b75b8944
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Cache\Cache;
/**
* Customers also bought block.
......@@ -159,9 +160,6 @@ class CustomersAlsoBoughtBlock extends BlockBase implements ContainerFactoryPlug
return [
'#theme' => 'customers_also_bought',
'#products' => $this->getRenderedProducts($product_ids, $number_of_products, $this->configuration['view_mode']),
'#cache' => [
'max-age' => $this->configuration['max_age'],
],
];
}
else {
......@@ -289,4 +287,25 @@ class CustomersAlsoBoughtBlock extends BlockBase implements ContainerFactoryPlug
return $random_products;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return Cache::mergeContexts(parent::getCacheContexts(), ['url']);
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return Cache::mergeTags(parent::getCacheTags(), ['commerce_product_list']);
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::mergeMaxAges(parent::getCacheMaxAge(), $this->configuration['max_age']);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment