Skip to content

Commit 2e7406a

Browse files
authored
Merge pull request #1694 from algolia/release/3.15.0-dev
MAGE-1117: Update `3.15.0-beta` branch
2 parents 8d0526a + d280dc2 commit 2e7406a

File tree

114 files changed

+7104
-4194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+7104
-4194
lines changed

Api/Data/IndexOptionsInterface.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Api\Data;
4+
5+
interface IndexOptionsInterface
6+
{
7+
const STORE_ID = 'store_id';
8+
9+
const INDEX_SUFFIX = 'index_suffix';
10+
11+
const IS_TMP = 'is_tmp';
12+
13+
const INDEX_NAME = 'index_name';
14+
15+
/**
16+
* Get field: store_id
17+
*
18+
* @return int|null
19+
*/
20+
public function getStoreId(): ?int;
21+
22+
/**
23+
* Get field: index_suffix
24+
*
25+
* @return string|null
26+
*/
27+
public function getIndexSuffix(): ?string;
28+
29+
/**
30+
* Get field: is_tmp
31+
*
32+
* @return bool
33+
*/
34+
public function isTemporaryIndex(): bool;
35+
36+
/**
37+
* Get field: index_name
38+
*
39+
* @return string|null
40+
*/
41+
public function getIndexName(): ?string;
42+
43+
/**
44+
* Set field: index_name
45+
*
46+
* @param string $indexName
47+
* @return void
48+
*/
49+
public function setIndexName(string $indexName): void;
50+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Api\IndexBuilder;
4+
5+
interface IndexBuilderInterface
6+
{
7+
public function buildIndex(int $storeId, ?array $entityIds, ?array $options): void;
8+
9+
public function buildIndexFull(int $storeId, ?array $options): void;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Api\IndexBuilder;
4+
5+
interface UpdatableIndexBuilderInterface extends IndexBuilderInterface
6+
{
7+
public function buildIndexList(int $storeId, ?array $entityIds, ?array $options): void;
8+
}

Block/Configuration.php

+16-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Configuration extends Algolia implements CollectionDataSourceInterface
1313
//Placeholder for future implementation (requires custom renderer for hierarchicalMenu widget)
1414
private const IS_CATEGORY_NAVIGATION_ENABLED = false;
1515

16-
public function isSearchPage()
16+
public function isSearchPage(): bool
1717
{
1818
if ($this->getConfigHelper()->isInstantEnabled()) {
1919
/** @var Http $request */
@@ -80,8 +80,6 @@ public function getConfiguration()
8080

8181
$suggestionHelper = $this->getSuggestionHelper();
8282

83-
$productHelper = $this->getProductHelper();
84-
8583
$algoliaHelper = $this->getAlgoliaHelper();
8684

8785
$persoHelper = $this->getPersonalizationHelper();
@@ -249,12 +247,13 @@ public function getConfiguration()
249247
'indexName' => $coreHelper->getBaseIndexName(),
250248
'apiKey' => $algoliaHelper->generateSearchSecuredApiKey(
251249
$config->getSearchOnlyAPIKey(),
252-
$attributesToFilter
250+
$attributesToFilter,
251+
$this->getStoreId()
253252
),
254253
'attributeFilter' => $attributesToFilter,
255254
'facets' => $facets,
256255
'areCategoriesInFacets' => $areCategoriesInFacets,
257-
'hitsPerPage' => (int) $config->getNumberOfProductResults(),
256+
'hitsPerPage' => $config->getNumberOfProductResults(),
258257
'sortingIndices' => array_values($this->sortingTransformer->getSortingIndices(
259258
$this->getStoreId(),
260259
$customerGroupId
@@ -421,7 +420,7 @@ protected function getOrderedProductIds(ConfigHelper $configHelper, Http $reques
421420
return $ids;
422421
}
423422

424-
protected function isLandingPage()
423+
protected function isLandingPage(): bool
425424
{
426425
return $this->getRequest()->getFullActionName() === 'algolia_landingpage_view';
427426
}
@@ -440,4 +439,15 @@ protected function getLandingPageConfiguration()
440439
{
441440
return $this->isLandingPage() ? $this->getCurrentLandingPage()->getConfiguration() : json_encode([]);
442441
}
442+
443+
public function canLoadInstantSearch(): bool
444+
{
445+
return $this->getConfigHelper()->isInstantEnabled()
446+
&& $this->isProductListingPage();
447+
}
448+
449+
protected function isProductListingPage(): bool
450+
{
451+
return $this->isSearchPage() || $this->isLandingPage();
452+
}
443453
}

CHANGELOG.md

+71-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,53 @@
11
# CHANGE LOG
22

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

5-
## Updates
6-
- Added support for Multi-Application IDs
5+
### 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))
8+
- Added support for core Algolia UI library overrides via RequireJS
9+
- 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)
10+
- 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
11+
- 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.)
13+
14+
### Updates
15+
- Tests: Added possibility to run tests with multiple applications IDs.
16+
- Introduced Index Builders which are services responsible for creating and filling indices with data.
17+
- **IMPORTANT**: As a result `AlgoliaHelper` is now deprecated and will be removed from the codebase in version 3.16.0
18+
- Added `BackendSearch` Service to move `getSearchResults` method into.
19+
- Updated Indexing Queue display in the admin by adding the `class` column
20+
- Updated Indexing Queue `data` column formatting
21+
- Added documentation link on the queue archive page
22+
- Debugging information now writes to `algolia.log`
23+
- Removed dependency on `algoliaBundle` package
24+
- 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))
26+
- JavaScript bundling is supported but to use the RequireJS Optimizer transpiling will be needed for ES6 constructs
27+
28+
### Bug Fixes
29+
- Fixed a bug where admin menus didn't display properly on Magento 2.4.7
30+
- Fixed customer groups prices ranges on configurable products
31+
- Fixed a bug where categories highlighting didn't work as expected on PLP powered by InstantSearch
32+
33+
### 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+
36+
37+
38+
## 3.14.4
39+
40+
### Features
41+
- Added a feature to enable automatic price indexing on the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products.)
42+
43+
### Updates
44+
- Updated `getCookie` method to make it more consistent
45+
- Removed dependency to `catalog_product_price` indexer
46+
47+
### Bug Fixes
48+
- Fixed a bug where the Landing Page Builder was crashing on save with customer group pricing was enabled.
49+
- Fixed issue where Insights information wasn't kept on the url after clicking "add to cart" on PLP powered by InstantSearch
50+
- Fixed a bug where synonyms were unintentionally duplicated on the Algolia dashboard
751

852
## 3.14.3
953

@@ -103,6 +147,30 @@ If you have customized your Algolia implementation or are running on an older ve
103147
- Added stronger typing to affected classes and methods
104148
- Added Looking Similar recommendations
105149

150+
## 3.13.8
151+
152+
### Bug Fixes
153+
- Restored compatibility with PHP 7.4
154+
155+
## 3.13.7
156+
157+
### Features
158+
- Added a feature to enable automatic price indexing on the Advanced section of the configuration (This feature should help alleviate issues where missing pricing records prevent Algolia from being able to index products.)
159+
160+
### Updates
161+
- Updated `getCookie` method to make it more consistent
162+
- Removed dependency to `catalog_product_price` indexer
163+
164+
### Bug Fixes
165+
- Fixed a bug where the Landing Page Builder was crashing on save with customer group pricing was enabled.
166+
- Fixed issue where Insights information wasn't kept on the url after clicking "add to cart" on PLP powered by InstantSearch
167+
168+
## 3.13.6
169+
170+
### Bug Fixes
171+
- Improve handling of insights params for URLs that already have a query string
172+
- Improve query method for alternate root categories - Thank you @igorfigueiredogen
173+
106174
## 3.13.5
107175

108176
### Updates

Controller/Adminhtml/Landingpage/Save.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ public function execute()
107107
$data['configuration'] = $data['algolia_configuration'];
108108
if ($this->configHelper->isCustomerGroupsEnabled($data['store_id'])) {
109109
$configuration = json_decode($data['algolia_configuration'], true);
110-
$priceConfig = $configuration['price'.$data['price_key']];
111-
$customerGroups = $this->customerGroupCollectionFactory->create();
112-
$store = $this->storeManager->getStore($data['store_id']);
113-
$baseCurrencyCode = $store->getBaseCurrencyCode();
114-
foreach ($customerGroups as $group) {
115-
$groupId = (int) $group->getData('customer_group_id');
116-
$configuration['price.'.$baseCurrencyCode.'.group_'.$groupId] = $priceConfig;
110+
if (isset($configuration['price'.$data['price_key']])) {
111+
$priceConfig = $configuration['price'.$data['price_key']];
112+
$customerGroups = $this->customerGroupCollectionFactory->create();
113+
$store = $this->storeManager->getStore($data['store_id']);
114+
$baseCurrencyCode = $store->getBaseCurrencyCode();
115+
foreach ($customerGroups as $group) {
116+
$groupId = (int) $group->getData('customer_group_id');
117+
$configuration['price.'.$baseCurrencyCode.'.group_'.$groupId] = $priceConfig;
118+
}
117119
}
118120
$data['configuration'] = json_encode($configuration);
119121
}

Controller/Adminhtml/Reindex/Save.php

+10-29
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,27 @@
99
use Algolia\AlgoliaSearch\Exception\UnknownSkuException;
1010
use Algolia\AlgoliaSearch\Helper\Data as DataHelper;
1111
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
12+
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
1213
use Magento\Backend\App\Action\Context;
1314
use Magento\Catalog\Api\ProductRepositoryInterface;
1415
use Magento\Framework\Controller\ResultFactory;
16+
use Magento\Framework\Exception\LocalizedException;
1517
use Magento\Framework\Exception\NoSuchEntityException;
1618
use Magento\Store\Model\StoreManagerInterface;
1719

1820
class Save extends \Magento\Backend\App\Action
1921
{
2022
public const MAX_SKUS = 10;
2123

22-
/** @var ProductRepositoryInterface */
23-
protected $productRepository;
24-
25-
/** @var StoreManagerInterface */
26-
protected $storeManager;
27-
28-
/** @var DataHelper */
29-
protected $dataHelper;
30-
31-
/** @var ProductHelper */
32-
protected $productHelper;
33-
34-
/**
35-
* @param Context $context
36-
* @param ProductRepositoryInterface $productRepository
37-
* @param StoreManagerInterface $storeManager
38-
* @param DataHelper $dataHelper
39-
* @param ProductHelper $productHelper
40-
*/
4124
public function __construct(
42-
Context $context,
43-
ProductRepositoryInterface $productRepository,
44-
StoreManagerInterface $storeManager,
45-
DataHelper $dataHelper,
46-
ProductHelper $productHelper
25+
protected Context $context,
26+
protected ProductRepositoryInterface $productRepository,
27+
protected StoreManagerInterface $storeManager,
28+
protected DataHelper $dataHelper,
29+
protected ProductHelper $productHelper,
30+
protected ProductIndexBuilder $productIndexBuilder
4731
) {
4832
parent::__construct($context);
49-
$this->storeManager = $storeManager;
50-
$this->dataHelper = $dataHelper;
51-
$this->productHelper = $productHelper;
52-
$this->productRepository = $productRepository;
5333
}
5434

5535
/**
@@ -131,6 +111,7 @@ public function execute()
131111
* @param $stores
132112
* @return void
133113
* @throws NoSuchEntityException
114+
* @throws LocalizedException
134115
*/
135116
protected function checkAndReindex($product, $stores)
136117
{
@@ -220,7 +201,7 @@ protected function checkAndReindex($product, $stores)
220201
$productIds = [$product->getId()];
221202
$productIds = array_merge($productIds, $this->productHelper->getParentProductIds($productIds));
222203

223-
$this->dataHelper->rebuildStoreProductIndex($storeId, $productIds);
204+
$this->productIndexBuilder->buildIndexList($storeId, $productIds);
224205
$this->messageManager->addSuccessMessage(
225206
__(
226207
'The Product "%1" (%2) has been reindexed for store "%3 / %4 / %5".',

Exception/DiagnosticsException.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Exception;
4+
5+
use Magento\Framework\Exception\LocalizedException;
6+
7+
class DiagnosticsException extends LocalizedException
8+
{
9+
10+
}

Helper/AdapterHelper.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Algolia\AlgoliaSearch\Helper;
44

55
use Algolia\AlgoliaSearch\Helper\Adapter\FiltersHelper;
6-
use Algolia\AlgoliaSearch\Helper\Data as AlgoliaDataHelper;
76
use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager;
7+
use Algolia\AlgoliaSearch\Service\Product\BackendSearch;
88
use Magento\CatalogSearch\Helper\Data as CatalogSearchDataHelper;
99

1010
class AdapterHelper
@@ -14,7 +14,7 @@ class AdapterHelper
1414

1515
public function __construct(
1616
protected CatalogSearchDataHelper $catalogSearchHelper,
17-
protected AlgoliaDataHelper $algoliaHelper,
17+
protected BackendSearch $backendSearch,
1818
protected FiltersHelper $filtersHelper,
1919
protected ConfigHelper $configHelper,
2020
protected AlgoliaCredentialsManager $algoliaCredentialsManager
@@ -52,7 +52,7 @@ public function getDocumentsFromAlgolia()
5252
}
5353
}
5454

55-
return $this->algoliaHelper->getSearchResult($algoliaQuery, $storeId, $searchParams, $targetedIndex);
55+
return $this->backendSearch->getSearchResult($algoliaQuery, $storeId, $searchParams, $targetedIndex);
5656
}
5757

5858
/**

0 commit comments

Comments
 (0)