Skip to content

Commit db7700b

Browse files
committed
MAGE-1228 Update 3.16 with latest changes to 3.15 pre-release
2 parents cb986d0 + 9af321c commit db7700b

34 files changed

+656
-107
lines changed

CHANGELOG.md

+7-40
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# CHANGE LOG
22

3-
## 3.15.0-beta.2
3+
## 3.15.0
44

55
### Features
6-
- Added support for Multi-Application IDs (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/getting-started/quick-start/#support-for-multiple-application-ids))
7-
- Refactored frontend library to no longer utilize the legacy `algoliaBundle` (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/customize/custom-front-end-events/?client=php#frontend-javascript-libraries-and-the-legacy-bundle))
6+
- Added support for Multi-Application IDs (see [documentation](https://www.algolia.com/doc/integration/magento-2/getting-started/quick-start/#support-for-multiple-application-ids))
7+
- Refactored frontend library to no longer utilize the legacy `algoliaBundle` (see [documentation](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/?client=php#frontend-javascript-libraries-and-the-legacy-bundle))
88
- Added support for core Algolia UI library overrides via RequireJS
99
- Added support for mixins through RequireJS in addition to [front end custom events](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events)
1010
- See our `CustomAlgolia` demo extension's [1.4.0 release](https://github.com/algolia/algoliasearch-custom-algolia-magento-2/releases/tag/1.4.0) for examples on how to take advantage of these changes
1111
- Added granular profiling through the [Magento Profiler](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/setup/mage-profiler) to aid in troubleshooting indexing performance issues
12-
- Added a feature to enable automatic price indexing within the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products. See [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/troubleshooting/data-indexes-queues/#price-index-dependencies) for further details.)
12+
- Added a feature to enable automatic price indexing within the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products. See [documentation](https://www.algolia.com/doc/integration/magento-2/troubleshooting/data-indexes-queues/#price-index-dependencies) for further details.)
1313

1414
### Updates
1515
- Tests: Added possibility to run tests with multiple applications IDs.
@@ -22,17 +22,17 @@
2222
- Debugging information now writes to `algolia.log`
2323
- Removed dependency on `algoliaBundle` package
2424
- Removed dependency on JavaScript global `window` objects with the exception of `algoliaConfig`
25-
- The Hogan.js library is still packaged for injection as needed but be advised that Mustache.js is now used internally instead (see [preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/customize/instant-search-page/?client=php#mustache-templates))
25+
- The Hogan.js library is still packaged for injection as needed but be advised that Mustache.js is now used internally instead (see [documentation](https://www.algolia.com/doc/integration/magento-2/customize/instant-search-page/?client=php#mustache-templates))
2626
- JavaScript bundling is supported but to use the RequireJS Optimizer transpiling will be needed for ES6 constructs
2727

2828
### Bug Fixes
2929
- Fixed a bug where admin menus didn't display properly on Magento 2.4.7
3030
- Fixed customer groups prices ranges on configurable products
3131
- Fixed a bug where categories highlighting didn't work as expected on PLP powered by InstantSearch
32+
- Fixed a bug where excluded websites weren't taken into account while indexing customer prices on products. (thanks @kamilszewczyk)
3233

3334
### Breaking Changes
34-
- If you have customized your front end implementation based on the `algoliaBundle` you may need to shim your application accordingly (Full details are shared in [our preview documentation](https://deploy-preview-9703--algolia-docs.netlify.app/doc/integration/magento-2/troubleshooting/front-end-issues/))
35-
35+
- If you have customized your front end implementation based on the `algoliaBundle` you may need to shim your application accordingly (Full details are shared in [our documentation](https://www.algolia.com/doc/integration/magento-2/troubleshooting/front-end-issues/))
3636

3737

3838
## 3.14.4
@@ -128,25 +128,6 @@ If you have customized your Algolia implementation or are running on an older ve
128128
- Dropped support for Magento 2.3
129129
- PHP 8.1+ required
130130

131-
## 3.14.0-beta.2
132-
133-
### Updates
134-
135-
- Introduced new admin groups to InstantSearch for improved UX
136-
- Updated `ConfigHelper` to use new paths
137-
- Added data patch to migrate old configurations
138-
- Bugfix for query rule disable on facets with new admin groupings
139-
- Added new sorting admin option via source model
140-
- Added derived virtual replica enablement to `ConfigHelper` based on `ArraySerialized`
141-
- Intro’d simplified data structures to avoid array diff mismatches
142-
- Intro’d new `ReplicaManager` abstraction to map Magento sorting to Algolia replica configuration
143-
- Removed dependencies in backend models to handle replica config updates in Algolia addressing stale data
144-
- Added `ReplicaState` registry for tracking changes to sorting configuration to minimize number of replica build operations
145-
- Added logic to preserve replicas created outside of Magento such as Merchandising Studio "sorting strategies"
146-
- Introduced PHP 8 constructor property promotion on affected classes
147-
- Added stronger typing to affected classes and methods
148-
- Added Looking Similar recommendations
149-
150131
## 3.13.8
151132

152133
### Bug Fixes
@@ -188,20 +169,6 @@ If you have customized your Algolia implementation or are running on an older ve
188169
- Fixed lock timeout issue on indexing queue integration test
189170
- Community fix added - job queue dropping jobs from sandwiched full reindexes - thank you @pikulsky
190171

191-
## 3.14.0-beta.1
192-
193-
### Updates:
194-
195-
- New PHP API client (v4) under the hood for communicating with Algolia
196-
- Authenticated user tokens now utilized for backend and frontend events to track entire customer journey
197-
- Revenue data now sent with all events including application of Magento specific discounts such as catalog price rules and customer group pricing
198-
- Support for event subtypes allowing the capture of conversion data for both "Add to cart" and "Place order" events
199-
- Increased protection of PII in the event data
200-
201-
### Bug fixes:
202-
- Fixed issue with how Algolia extension handles end user consent for allowing cookies
203-
- Improved handling of user tokens across insights events and corresponding queries
204-
205172
## 3.13.3
206173

207174
### Updates

Helper/ConfigHelper.php

+1
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ public function getExtraSettings($section, $storeId = null)
13861386
/**
13871387
* @param $storeId
13881388
* @return bool
1389+
* @deprecated This feature is deprecated and will be replaced in an upcoming version
13891390
*/
13901391
public function preventBackendRendering($storeId = null)
13911392
{

Plugin/RenderingCacheContextPlugin.php

+69-22
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
66
use Magento\Framework\App\Http\Context as HttpContext;
77
use Magento\Framework\App\Request\Http;
8+
use Magento\Framework\Exception\NoSuchEntityException;
89
use Magento\Store\Model\StoreManagerInterface;
10+
use Magento\UrlRewrite\Model\UrlFinderInterface;
911

1012
/**
1113
* The purpose of this class is to render different cached versions of the pages according to the user agent.
@@ -15,39 +17,36 @@
1517
*/
1618
class RenderingCacheContextPlugin
1719
{
18-
public const RENDERING_CONTEXT = 'rendering_context';
20+
public const RENDERING_CONTEXT = 'algolia_rendering_context';
1921
public const RENDERING_WITH_BACKEND = 'with_backend';
2022
public const RENDERING_WITHOUT_BACKEND = 'without_backend';
2123

22-
private $configHelper;
23-
private $storeManager;
24-
private $request;
24+
public const CATEGORY_CONTROLLER = 'category';
25+
public const CATEGORY_ROUTE = 'catalog/category/view';
2526

2627
public function __construct(
27-
ConfigHelper $configHelper,
28-
StoreManagerInterface $storeManager,
29-
Http $request
30-
) {
31-
$this->configHelper = $configHelper;
32-
$this->storeManager = $storeManager;
33-
$this->request = $request;
34-
}
28+
protected ConfigHelper $configHelper,
29+
protected StoreManagerInterface $storeManager,
30+
protected Http $request,
31+
protected UrlFinderInterface $urlFinder
32+
) { }
3533

3634
/**
37-
* Add Rendering context for caching purposes
38-
* (If the prevent rendering configuration is enabled and the user agent has no white card to display it,
35+
* Add a rendering context to the vary string data to distinguish which versions of the category PLP should be cached
36+
* (If the "prevent backend rendering" configuration is enabled and the user agent is not whitelisted to display it,
3937
* we set a different page variation, and the FPC stores a different cached page)
4038
*
41-
* @param HttpContext $subject
42-
* @param string[] $data
39+
* IMPORTANT:
40+
* Magento\Framework\App\Http\Context::getData can be called multiple times over the course of the request lifecycle
41+
* it is important that this plugin return the data consistently - or the cache will be invalidated unexpectedly!
4342
*
44-
* @return array
43+
* @param HttpContext $subject
44+
* @param array $data
45+
* @return array original params
46+
* @throws NoSuchEntityException
4547
*/
46-
public function afterGetData(HttpContext $subject, $data)
47-
{
48-
$storeId = $this->storeManager->getStore()->getId();
49-
if (!($this->request->getControllerName() === 'category'
50-
&& $this->configHelper->replaceCategories($storeId) === true)) {
48+
public function afterGetData(HttpContext $subject, array $data): array {
49+
if (!$this->shouldApplyCacheContext()) {
5150
return $data;
5251
}
5352

@@ -59,4 +58,52 @@ public function afterGetData(HttpContext $subject, $data)
5958

6059
return $data;
6160
}
61+
62+
/**
63+
* @param int $storeId
64+
* @return string
65+
*/
66+
protected function getOriginalRoute(int $storeId): string
67+
{
68+
$requestUri = $this->request->getRequestUri();
69+
70+
$rewrite = $this->urlFinder->findOneByData([
71+
'request_path' => ltrim($requestUri, '/'),
72+
'store_id' => $storeId,
73+
]);
74+
75+
return $rewrite?->getTargetPath() ?? "";
76+
}
77+
78+
/**
79+
* @param string $path
80+
* @return bool
81+
*/
82+
protected function isCategoryRoute(string $path): bool {
83+
$path = ltrim($path, '/');
84+
return str_starts_with($path, self::CATEGORY_ROUTE);
85+
}
86+
87+
/**
88+
* This can be called in a variety of contexts - so this should always be called consistently
89+
*
90+
* @param int $storeId
91+
* @return bool
92+
*/
93+
protected function isCategoryPage(int $storeId): bool
94+
{
95+
return $this->request->getControllerName() === self::CATEGORY_CONTROLLER
96+
|| $this->isCategoryRoute($this->request->getRequestUri())
97+
|| $this->isCategoryRoute($this->getOriginalRoute($storeId));
98+
}
99+
100+
/**
101+
* @return bool
102+
* @throws NoSuchEntityException
103+
*/
104+
protected function shouldApplyCacheContext(): bool
105+
{
106+
$storeId = $this->storeManager->getStore()->getId();
107+
return $this->isCategoryPage($storeId) && $this->configHelper->replaceCategories($storeId);
108+
}
62109
}

0 commit comments

Comments
 (0)