Skip to content

Commit 5e949fb

Browse files
committed
MAGE-1378 Alter cache vary logic to preserve X-Magento-Vary cookie for Varnish and disable replace category pages by default
1 parent 8483eb1 commit 5e949fb

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Plugin/RenderingCacheContextPlugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Algolia\AlgoliaSearch\Plugin;
44

55
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
6+
use Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper;
67
use Magento\Framework\App\Http\Context as HttpContext;
78
use Magento\Framework\App\Request\Http;
89
use Magento\Framework\Exception\NoSuchEntityException;
@@ -25,7 +26,8 @@ class RenderingCacheContextPlugin
2526
public const CATEGORY_ROUTE = 'catalog/category/view';
2627

2728
public function __construct(
28-
protected ConfigHelper $configHelper,
29+
protected ConfigHelper $baseConfig,
30+
protected InstantSearchHelper $isConfig,
2931
protected StoreManagerInterface $storeManager,
3032
protected Http $request,
3133
protected UrlFinderInterface $urlFinder
@@ -50,7 +52,7 @@ public function afterGetData(HttpContext $subject, array $data): array {
5052
return $data;
5153
}
5254

53-
$context = $this->configHelper->preventBackendRendering() ?
55+
$context = $this->baseConfig->preventBackendRendering() ?
5456
self::RENDERING_WITHOUT_BACKEND :
5557
self::RENDERING_WITH_BACKEND;
5658

@@ -89,6 +91,7 @@ protected function isCategoryRoute(string $path): bool {
8991
*
9092
* @param int $storeId
9193
* @return bool
94+
* @deprecated This method will be removed in a future version
9295
*/
9396
protected function isCategoryPage(int $storeId): bool
9497
{
@@ -104,6 +107,6 @@ protected function isCategoryPage(int $storeId): bool
104107
protected function shouldApplyCacheContext(): bool
105108
{
106109
$storeId = $this->storeManager->getStore()->getId();
107-
return $this->isCategoryPage($storeId) && $this->configHelper->replaceCategories($storeId);
110+
return $this->isConfig->shouldReplaceCategories($storeId);
108111
}
109112
}

Setup/Patch/Schema/ConfigPatch.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class ConfigPatch implements SchemaPatchInterface
5151
'algoliasearch_instant/instant/instant_selector' => '.columns',
5252
'algoliasearch_instant/instant/number_product_results' => '9',
5353
'algoliasearch_instant/instant/max_values_per_facet' => '10',
54-
'algoliasearch_instant/instant/replace_categories' => '1',
5554
'algoliasearch_instant/instant/show_suggestions_on_no_result_page' => '1',
5655
'algoliasearch_instant/instant/add_to_cart_enable' => '1',
5756
'algoliasearch_instant/instant/infinite_scroll_enable' => '0',

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": ["MIT"],
66
"version": "3.16.0",
77
"require": {
8-
"php": "~8.1|~8.2|~8.3",
8+
"php": "~8.2|~8.3|~8.4",
99
"magento/framework": "~103.0",
1010
"algolia/algoliasearch-client-php": "4.18.3",
1111
"guzzlehttp/guzzle": "^6.3.3|^7.3.0",

etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
</redirects>
3030
</algoliasearch_autocomplete>
3131
<algoliasearch_instant>
32+
<instant>
33+
<replace_categories>0</replace_categories>
34+
</instant>
3235
<instant_facets>
3336
<facets><![CDATA[{"_1458145454535_587":{"attribute":"price","type":"slider","label":"Price","searchable":"2","create_rule":"2"},"_2541608784525_123":{"attribute":"categories","type":"conjunctive","label":"Categories","searchable":"2","create_rule":"2"},"_3211608784535_456":{"attribute":"color","type":"disjunctive","label":"Colors","searchable":"1","create_rule":"2"}}]]></facets>
3437
<max_values_per_facet>10</max_values_per_facet>

0 commit comments

Comments
 (0)