';
+ return $html;
+ }
+}
diff --git a/Block/Algolia.php b/Block/Algolia.php
index 528626603..01113b45f 100755
--- a/Block/Algolia.php
+++ b/Block/Algolia.php
@@ -2,8 +2,9 @@
namespace Algolia\AlgoliaSearch\Block;
-use Algolia\AlgoliaSearch\Helper\AlgoliaHelper;
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
+use Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper;
+use Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper;
use Algolia\AlgoliaSearch\Helper\Configuration\PersonalizationHelper;
use Algolia\AlgoliaSearch\Helper\Data as CoreHelper;
use Algolia\AlgoliaSearch\Helper\Entity\CategoryHelper;
@@ -13,6 +14,7 @@
use Algolia\AlgoliaSearch\Model\LandingPage as LandingPageModel;
use Algolia\AlgoliaSearch\Registry\CurrentCategory;
use Algolia\AlgoliaSearch\Registry\CurrentProduct;
+use Algolia\AlgoliaSearch\Service\AlgoliaConnector;
use Algolia\AlgoliaSearch\Service\Product\SortingTransformer;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -40,12 +42,15 @@ class Algolia extends Template implements CollectionDataSourceInterface
public function __construct(
protected ConfigHelper $config,
+ protected AutocompleteHelper $autocompleteConfig,
+ protected InstantSearchHelper $instantSearchConfig,
+ protected PersonalizationHelper $personalizationHelper,
protected CatalogSearchHelper $catalogSearchHelper,
protected ProductHelper $productHelper,
protected Currency $currency,
protected Format $format,
protected CurrentProduct $currentProduct,
- protected AlgoliaHelper $algoliaHelper,
+ protected AlgoliaConnector $algoliaConnector,
protected UrlHelper $urlHelper,
protected FormKey $formKey,
protected HttpContext $httpContext,
@@ -53,7 +58,6 @@ public function __construct(
protected CategoryHelper $categoryHelper,
protected SuggestionHelper $suggestionHelper,
protected LandingPageHelper $landingPageHelper,
- protected PersonalizationHelper $personalizationHelper,
protected CheckoutSession $checkoutSession,
protected DateTime $date,
protected CurrentCategory $currentCategory,
@@ -103,11 +107,6 @@ public function getCatalogSearchHelper(): CatalogSearchHelper
return $this->catalogSearchHelper;
}
- public function getAlgoliaHelper(): AlgoliaHelper
- {
- return $this->algoliaHelper;
- }
-
public function getPersonalizationHelper(): PersonalizationHelper
{
return $this->personalizationHelper;
@@ -208,7 +207,7 @@ protected function getAddToCartUrl($additional = []): string
$urlParamName = ActionInterface::PARAM_NAME_URL_ENCODED;
$routeParams = [
$urlParamName => $continueUrl,
- '_secure' => $this->algoliaHelper->getRequest()->isSecure(),
+ '_secure' => $this->getRequest()->isSecure(),
];
if ($additional !== []) {
$routeParams = array_merge($routeParams, $additional);
diff --git a/Block/Checkout/Conversion.php b/Block/Checkout/Conversion.php
index 0eb95b4bd..b1f314183 100644
--- a/Block/Checkout/Conversion.php
+++ b/Block/Checkout/Conversion.php
@@ -54,7 +54,7 @@ public function getOrderItemsConversionJson()
/** @var Item $item */
foreach ($orderItems as $item) {
if ($item->hasData(InsightsHelper::QUOTE_ITEM_QUERY_PARAM)) {
- $orderItemsData[$item->getProductId()] = json_decode($item->getData(InsightsHelper::QUOTE_ITEM_QUERY_PARAM));
+ $orderItemsData[$item->getProductId()] = json_decode((string) $item->getData(InsightsHelper::QUOTE_ITEM_QUERY_PARAM));
}
}
diff --git a/Block/Configuration.php b/Block/Configuration.php
index 58e7c09ac..f788e5473 100755
--- a/Block/Configuration.php
+++ b/Block/Configuration.php
@@ -4,6 +4,8 @@
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Algolia\AlgoliaSearch\Helper\InsightsHelper;
+use Algolia\AlgoliaSearch\Model\Source\AutocompleteRedirectMode;
+use Algolia\AlgoliaSearch\Model\Source\InstantSearchRedirectOptions;
use Magento\Framework\App\Request\Http;
use Magento\Framework\Data\CollectionDataSourceInterface;
use Magento\Framework\DataObject;
@@ -55,7 +57,7 @@ protected function initCategoryParentPath(\Magento\Catalog\Model\Category $cat):
* @param array $arr
* @return array
*/
- protected function getChildCategoryUrls(\Magento\Catalog\Model\Category $cat, string $parent = '', array $arr = array()): array {
+ protected function getChildCategoryUrls(\Magento\Catalog\Model\Category $cat, string $parent = '', array $arr = []): array {
if (!$parent) {
$parent = $this->initCategoryParentPath($cat);
}
@@ -80,7 +82,7 @@ public function getConfiguration()
$suggestionHelper = $this->getSuggestionHelper();
- $algoliaHelper = $this->getAlgoliaHelper();
+ $algoliaConnector = $this->algoliaConnector;
$persoHelper = $this->getPersonalizationHelper();
@@ -185,32 +187,8 @@ public function getConfiguration()
$attributesToFilter = $config->getAttributesToFilter($customerGroupId);
$algoliaJsConfig = [
- 'instant' => [
- 'enabled' => $config->isInstantEnabled(),
- 'selector' => $config->getInstantSelector(),
- 'isAddToCartEnabled' => $config->isAddToCartEnable(),
- 'addToCartParams' => $addToCartParams,
- 'infiniteScrollEnabled' => $config->isInfiniteScrollEnabled(),
- 'urlTrackedParameters' => $this->getUrlTrackedParameters(),
- 'isSearchBoxEnabled' => $config->isInstantSearchBoxEnabled(),
- 'isVisualMerchEnabled' => $config->isVisualMerchEnabled(),
- 'categorySeparator' => $config->getCategorySeparator(),
- 'categoryPageIdAttribute' => $config->getCategoryPageIdAttributeName(),
- 'isCategoryNavigationEnabled' => self::IS_CATEGORY_NAVIGATION_ENABLED,
- 'hidePagination' => $config->hidePaginationInInstantSearchPage()
- ],
- 'autocomplete' => [
- 'enabled' => $config->isAutoCompleteEnabled(),
- 'selector' => $config->getAutocompleteSelector(),
- 'sections' => $config->getAutocompleteSections(),
- 'nbOfProductsSuggestions' => $config->getNumberOfProductsSuggestions(),
- 'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
- 'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
- 'isDebugEnabled' => $config->isAutocompleteDebugEnabled(),
- 'isNavigatorEnabled' => $config->isAutocompleteNavigatorEnabled(),
- 'debounceMilliseconds' => $config->getAutocompleteDebounceMilliseconds(),
- 'minimumCharacters' => $config->getAutocompleteMinimumCharacterLength()
- ],
+ 'instant' => $this->getInstantSearchConfig($addToCartParams),
+ 'autocomplete' => $this->getAutocompleteConfiguration(),
'landingPage' => [
'query' => $this->getLandingPageQuery(),
'configuration' => $this->getLandingPageConfiguration(),
@@ -244,8 +222,10 @@ public function getConfiguration()
],
'extensionVersion' => $config->getExtensionVersion(),
'applicationId' => $config->getApplicationID(),
+ // Legacy misnomer - retained for backward compatibility
'indexName' => $coreHelper->getBaseIndexName(),
- 'apiKey' => $algoliaHelper->generateSearchSecuredApiKey(
+ 'baseIndexName' => $coreHelper->getBaseIndexName(),
+ 'apiKey' => $algoliaConnector->generateSearchSecuredApiKey(
$config->getSearchOnlyAPIKey(),
$attributesToFilter,
$this->getStoreId()
@@ -368,6 +348,7 @@ public function getConfiguration()
'products' => __('Products'),
'suggestions' => __('Suggestions'),
'searchBy' => __('Search by'),
+ 'redirectSearchPrompt' => __("Continue search for"),
'searchForFacetValuesPlaceholder' => __('Search for other ...'),
'showMore' => __('Show more products'),
'searchTitle' => __('Search results for'),
@@ -381,6 +362,59 @@ public function getConfiguration()
return $transport->getData();
}
+ protected function getAutocompleteConfiguration(): array
+ {
+ $config = $this->autocompleteConfig;
+ return [
+ 'enabled' => $config->isEnabled(),
+ 'selector' => $config->getDomSelector(),
+ 'sections' => $config->getAdditionalSections(),
+ 'nbOfProductsSuggestions' => $config->getNumberOfProductsSuggestions(),
+ 'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
+ 'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
+ 'isDebugEnabled' => $config->isDebugEnabled(),
+ 'isNavigatorEnabled' => $config->isKeyboardNavigationEnabled(),
+ 'debounceMilliseconds' => $config->getDebounceMilliseconds(),
+ 'minimumCharacters' => $config->getMinimumCharacterLength(),
+ 'redirects' => [
+ 'enabled' => $config->isRedirectEnabled(),
+ 'showSelectableRedirect' => $config->getRedirectMode() !== AutocompleteRedirectMode::SUBMIT_ONLY,
+ 'showHitsWithRedirect' => $config->getRedirectMode() !== AutocompleteRedirectMode::SELECTABLE_REDIRECT,
+ 'openInNewWindow' => $config->isRedirectInNewWindowEnabled()
+ ]
+ ];
+ }
+
+ protected function getInstantSearchConfig(array $addToCartParams): array
+ {
+ $config = $this->instantSearchConfig;
+ $redirectOptions = $config->getInstantRedirectOptions();
+ $mainConfig = $this->config;
+
+ return [
+ 'enabled' => $config->isEnabled(),
+ 'selector' => $config->getDomSelector(),
+ 'isAddToCartEnabled' => $config->isAddToCartEnabled(),
+ 'addToCartParams' => $addToCartParams,
+ 'infiniteScrollEnabled' => $config->isInfiniteScrollEnabled(),
+ 'urlTrackedParameters' => $this->getUrlTrackedParameters(),
+ 'isSearchBoxEnabled' => $config->isSearchBoxEnabled(),
+ 'isVisualMerchEnabled' => $mainConfig->isVisualMerchEnabled(),
+ 'categorySeparator' => $mainConfig->getCategorySeparator(),
+ 'categoryPageIdAttribute' => $mainConfig->getCategoryPageIdAttributeName(),
+ 'isCategoryNavigationEnabled' => self::IS_CATEGORY_NAVIGATION_ENABLED,
+ 'hidePagination' => $config->shouldHidePagination(),
+ 'isDynamicFacetsEnabled' => $config->isDynamicFacetsEnabled(),
+ 'redirects' => [
+ 'enabled' => $config->isInstantRedirectEnabled(),
+ 'onPageLoad' => in_array(InstantSearchRedirectOptions::REDIRECT_ON_PAGE_LOAD, $redirectOptions),
+ 'onSearchAsYouType' => in_array(InstantSearchRedirectOptions::REDIRECT_ON_SEARCH_AS_YOU_TYPE, $redirectOptions),
+ 'showSelectableRedirect' => in_array(InstantSearchRedirectOptions::SELECTABLE_REDIRECT, $redirectOptions),
+ 'openInNewWindow' => in_array(InstantSearchRedirectOptions::OPEN_IN_NEW_WINDOW, $redirectOptions)
+ ]
+ ];
+ }
+
protected function areCategoriesInFacets($facets)
{
return in_array('categories', array_column($facets, 'attribute'));
diff --git a/Block/LandingPage.php b/Block/LandingPage.php
index 7ee2c1423..a41ad2bef 100644
--- a/Block/LandingPage.php
+++ b/Block/LandingPage.php
@@ -90,7 +90,7 @@ protected function _prepareLayout()
$page = $this->getPage();
$this->pageConfig->addBodyClass('algolia-landingpage-' . $page->getUrlKey());
$metaTitle = $page->getMetaTitle();
- $this->pageConfig->getTitle()->set($page->getTitle() ? $page->getTitle() : $metaTitle);
+ $this->pageConfig->getTitle()->set($page->getTitle() ?: $metaTitle);
$this->pageConfig->setKeywords($page->getMetaKeywords());
$this->pageConfig->setDescription($page->getMetaDescription());
diff --git a/Block/Navigation/Renderer/SliderRenderer.php b/Block/Navigation/Renderer/SliderRenderer.php
index d29210871..9030aa310 100644
--- a/Block/Navigation/Renderer/SliderRenderer.php
+++ b/Block/Navigation/Renderer/SliderRenderer.php
@@ -158,6 +158,6 @@ private function getUrlTemplate()
$regexp = "/({$filter->getRequestVar()})=(-?[0-9A-Z\-\%]+)/";
$replacement = '${1}=<%- from %>-<%- to %>';
- return preg_replace($regexp, $replacement, $item->getUrl());
+ return preg_replace($regexp, $replacement, (string) $item->getUrl());
}
}
diff --git a/Block/System/Form/Field/Select.php b/Block/System/Form/Field/Select.php
index 164a605b4..a433413df 100755
--- a/Block/System/Form/Field/Select.php
+++ b/Block/System/Form/Field/Select.php
@@ -9,6 +9,6 @@ protected function _toHtml()
$this->setData('name', $this->getData('input_name'));
$this->setClass('select');
- return trim(preg_replace('/\s+/', ' ', parent::_toHtml()));
+ return trim((string) preg_replace('/\s+/', ' ', parent::_toHtml()));
}
}
diff --git a/Block/Widget/LookingSimilar.php b/Block/Widget/LookingSimilar.php
index e04cee45f..23c82a59c 100644
--- a/Block/Widget/LookingSimilar.php
+++ b/Block/Widget/LookingSimilar.php
@@ -51,7 +51,7 @@ public function generateUniqueToken()
*/
public function getProductIds()
{
- return json_encode(explode(",", $this->getData('productIds')));
+ return json_encode(explode(",", (string) $this->getData('productIds')));
}
/**
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8aa9e56ce..3464ba3c1 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,54 @@
# CHANGE LOG
+## 3.16.0
+
+### Features
+
+- Automatic full indexing has been deprecated in 3.16 - you can now opt out of Algolia initiating full reindexing from `indexer_reindex_all_invalid`.
+- Added an "Indexing Manager" section within the Algolia configuration which allows disabling automatic full reindexing with Magento indexers. **IMPORTANT: If you want to perform full reindexing, we highly suggest to turn this configuration off and run the newly created CLI commands instead.**
+- Added an "Indexing Manager" page which shows the created indices for main entities (products, categories and pages) and corresponding stores with a link to directly check them on the Algolia dashboard along with a form to reindex those entities directly from the Magento admin.
+- CLI commands are now provided to run explicit full reindex of all entities and stores.
+- Products and CMS pages can now be reindexed directly from Magento admin grids.
+- The indexing queue cron job can now be configured from the Magento admin.
+- Dynamic faceting through Algolia merchandising rules is now supported in Magento via an opt-in feature flag.
+- No code redirects via merchandising rules in Algolia are now supported in Magento for both Autocomplete and InstantSearch. Support is enabled by default for Autocomplete.
+- Settings updates are now automatically forwarded to replicas (if this behavior is not desirable it can be disabled in the admin)
+- Integration tests and unit tests added
+
+### Bug Fixes
+- Behavior of conjunctive vs disjunctive facets has been clarified.
+- Replica data patches and delete operations have been enhanced to handle potential latency when detaching from the primary index.
+- Prices are now indexed using store scoped currency codes.
+- Fixed WSOD error on invalid creds when using manual SKU indexer (also included in 3.15.1).
+- Fixed Recommend model validation when configuring through the Magento admin
+- Fixed edge case with null queries - thank you @PromInc
+- Removed conditional behavior on setting the vary string from the plugin on `\Magento\Framework\App\Http\Context` so that a consistent `X-Magento-Vary` cookie is sent across all requests
+
+### Updates
+- `beforecontent.html` is no longer used and has been deprecated. If you're overriding or referencing this file, please update your layout and customizations accordingly.
+- An additional separate crontab is no longer needed to run the indexing queue. Enable via admin config to run the queue using Magento's built-in cron.
+- `BatchQueueProcessorInterface` has been introduced to decouple Algolia operations for core `Indexer` models.
+- Magento will set a default `renderingContent` based on its configured facets. Be sure that "Facet Display" is supported by your Algolia plan before attempting to use.
+- Auto full indexing can be disabled in this release under Stores > Configuration > Algolia Search > Indexing Manager. We are moving towards more intentional indexing so please note that this will become the default in a future release.
+- InstantSearch has been refactored to support customization via JavaScript mixins.
+- A new front end hook called `beforeFacetInitialization` has been added which allows a user to extend the functionality by adding, removing or modifying "builder" functions which are used to define a facet config that will drive the rendering of facets.
+- Removed InstantSearch enablement dependency in Magento admin to prevent losing facet and sorting config when disabling the feature.
+- InstantSearch has been updated to v4.78.
+- Autocomplete has been updated to v1.18.1.
+- PHP API client has been pinned to 4.18.3 (also included in 3.15.1).
+- Credentials form expanded by default in admin
+- Removed deprecated methods from Entity Helpers
+- Removed every call to deprecated `AlgoliaHelper`'s methods in the codebase, `AlgoliaConnector` is now targeted directly. (`AlgoliaHelper` will be removed in a future v3.17.0)
+- Updated integration tests
+- Added support for PHPUnit 10
+- Added support for Magento 2.4.8 on PHP 8.4 - Special shout out to @jajajaime for his help here
+- Refactored code to PHP 8.2 baseline standard
+- Added string escaping to untrusted inputs
+- The InstantSearch "replace categories" feature must now be explicitly enabled on new instances aligning with our documentation: https://www.algolia.com/doc/integration/magento-2/guides/category-pages/#enable-category-pages
+
+### Breaking Changes
+- `ProductHelper::setSettings()` is now taking `IndexOptions` objects as two first parameters instead of index names (strings).
+
## 3.15.1
### Features
@@ -50,6 +99,7 @@
- Fixed a bug where categories highlighting didn't work as expected on PLP powered by InstantSearch
- Fixed a bug where excluded websites weren't taken into account while indexing customer prices on products. (thanks @kamilszewczyk)
- Fixed a bug where full page cache (FPC) didn't work on category pages
+- Fixed a bug where credentials errors weren't gracefully handled on the SKU reindexing form
### Breaking Changes
- 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/))
diff --git a/Console/Command/AbstractStoreCommand.php b/Console/Command/AbstractStoreCommand.php
index 18b5363fd..f6481f9c8 100644
--- a/Console/Command/AbstractStoreCommand.php
+++ b/Console/Command/AbstractStoreCommand.php
@@ -87,7 +87,7 @@ protected function getStoreIds(InputInterface $input): array
protected function validateStoreIds(array $storeIds): array
{
foreach ($storeIds as $storeId) {
- if (!ctype_digit($storeId) || (int) $storeId < 1) {
+ if (!ctype_digit((string) $storeId) || (int) $storeId < 1) {
throw new LocalizedException(__("Store ID argument must be an integer"));
}
}
@@ -123,7 +123,7 @@ protected function decorateOperationAnnouncementMessage(string $msg, array $stor
{
$msg = str_replace('{{target}}', $this->getOperationTargetLabel($storeIds), $msg);
return ($storeIds)
- ? "$msg: " . join(", ", $this->storeNameFetcher->getStoreNames($storeIds)) . ''
+ ? "$msg: " . implode(", ", $this->storeNameFetcher->getStoreNames($storeIds)) . ''
: "$msg";
}
diff --git a/Console/Command/Indexer/AbstractIndexerCommand.php b/Console/Command/Indexer/AbstractIndexerCommand.php
new file mode 100644
index 000000000..e8f77ab3d
--- /dev/null
+++ b/Console/Command/Indexer/AbstractIndexerCommand.php
@@ -0,0 +1,41 @@
+getStoreIds($input);
+
+ if (count($storeIds) === 0) {
+ $storeIds = array_keys($this->storeManager->getStores());
+ }
+
+ return $storeIds;
+ }
+}
diff --git a/Console/Command/Indexer/DeleteProductsCommand.php b/Console/Command/Indexer/DeleteProductsCommand.php
new file mode 100644
index 000000000..094e001ee
--- /dev/null
+++ b/Console/Command/Indexer/DeleteProductsCommand.php
@@ -0,0 +1,54 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln('Deleting inactive products for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->productBatchQueueProcessor->deleteInactiveProducts($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexAdditionalSectionsCommand.php b/Console/Command/Indexer/IndexAdditionalSectionsCommand.php
new file mode 100644
index 000000000..e03c9b023
--- /dev/null
+++ b/Console/Command/Indexer/IndexAdditionalSectionsCommand.php
@@ -0,0 +1,55 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln(
+ 'Reindexing additional sections for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->additionalSectionBatchQueueProcessorr->processBatch($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexAllCommand.php b/Console/Command/Indexer/IndexAllCommand.php
new file mode 100644
index 000000000..afa1cb374
--- /dev/null
+++ b/Console/Command/Indexer/IndexAllCommand.php
@@ -0,0 +1,64 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $output->writeln('Reindex all entities to Algolia (if the queue is enabled, indexing will be processed asynchronously)');
+ if (!$this->confirmOperation()) {
+ return CLI::RETURN_SUCCESS;
+ }
+
+ foreach ($this->commandsList as $commandName) {
+ $command = $this->getApplication()->find($commandName);
+ $command->run($input, $output);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexCategoriesCommand.php b/Console/Command/Indexer/IndexCategoriesCommand.php
new file mode 100644
index 000000000..b3e304205
--- /dev/null
+++ b/Console/Command/Indexer/IndexCategoriesCommand.php
@@ -0,0 +1,54 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln('Reindexing categories for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->categoryBatchQueueProcessor->processBatch($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexPagesCommand.php b/Console/Command/Indexer/IndexPagesCommand.php
new file mode 100644
index 000000000..c2aff07e6
--- /dev/null
+++ b/Console/Command/Indexer/IndexPagesCommand.php
@@ -0,0 +1,54 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln('Reindexing pages for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->pageBatchQueueProcessor->processBatch($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexProductsCommand.php b/Console/Command/Indexer/IndexProductsCommand.php
new file mode 100644
index 000000000..65c69089b
--- /dev/null
+++ b/Console/Command/Indexer/IndexProductsCommand.php
@@ -0,0 +1,54 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln('Reindexing products for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->productBatchQueueProcessor->processBatch($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/IndexSuggestionsCommand.php b/Console/Command/Indexer/IndexSuggestionsCommand.php
new file mode 100644
index 000000000..8d7951ef4
--- /dev/null
+++ b/Console/Command/Indexer/IndexSuggestionsCommand.php
@@ -0,0 +1,54 @@
+output = $output;
+ $this->input = $input;
+ $this->setAreaCode();
+
+ $storeIds = $this->getStoreIdsToIndex($input);
+
+ foreach ($storeIds as $storeId) {
+ $output->writeln('Reindexing suggestions for ' . $this->storeNameFetcher->getStoreName($storeId)) . '';
+ $this->suggestionBatchQueueProcessor->processBatch($storeId);
+ }
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/Indexer/ProcessQueueCommand.php b/Console/Command/Indexer/ProcessQueueCommand.php
new file mode 100644
index 000000000..13db37e56
--- /dev/null
+++ b/Console/Command/Indexer/ProcessQueueCommand.php
@@ -0,0 +1,68 @@
+setName($this->getCommandName())
+ ->setDescription($this->getCommandDescription());
+
+ parent::configure();
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $this->output = $output;
+ try {
+ $this->state->setAreaCode(Area::AREA_CRONTAB);
+ } catch (LocalizedException $e) {
+ // Area code is already set - nothing to do - but report regardless
+ $this->output->writeln("Unable to set area code due to the following error: " . $e->getMessage());
+ }
+
+ if (!$this->algoliaCredentialsManager->checkCredentialsWithSearchOnlyAPIKey()) {
+ $this->algoliaCredentialsManager->displayErrorMessage(self::class);
+
+ return Cli::RETURN_SUCCESS;
+ }
+
+ $this->queue->runCron();
+
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/Console/Command/ReplicaDisableVirtualCommand.php b/Console/Command/ReplicaDisableVirtualCommand.php
index 4e3e5e0ea..47efc00f4 100644
--- a/Console/Command/ReplicaDisableVirtualCommand.php
+++ b/Console/Command/ReplicaDisableVirtualCommand.php
@@ -139,9 +139,9 @@ protected function disableVirtualReplicasForStore(int $storeId): bool
protected function disableVirtualReplicasForAllStores(): void
{
- $this->configChecker->checkAndApplyAllScopes(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, [$this, 'removeLegacyVirtualReplicaConfig']);
+ $this->configChecker->checkAndApplyAllScopes(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, $this->removeLegacyVirtualReplicaConfig(...));
- $this->configChecker->checkAndApplyAllScopes(ConfigHelper::SORTING_INDICES, [$this, 'disableVirtualReplicaSortConfig']);
+ $this->configChecker->checkAndApplyAllScopes(ConfigHelper::SORTING_INDICES, $this->disableVirtualReplicaSortConfig(...));
$this->scopeConfig->reinit();
diff --git a/Console/Command/SynonymDeduplicateCommand.php b/Console/Command/SynonymDeduplicateCommand.php
index a85727e03..3f5f582c0 100644
--- a/Console/Command/SynonymDeduplicateCommand.php
+++ b/Console/Command/SynonymDeduplicateCommand.php
@@ -151,17 +151,13 @@ protected function dedupeSpecificSettings(array $settingNames, array $settings):
array_combine(
$settingNames,
array_map(
- function($settingName) use ($settings) {
- return isset($settings[$settingName])
- ? $this->dedupeArrayOfArrays($settings[$settingName])
- : null;
- },
+ fn($settingName) => isset($settings[$settingName])
+ ? $this->dedupeArrayOfArrays($settings[$settingName])
+ : null,
$settingNames
)
),
- function($val) {
- return $val !== null;
- }
+ fn($val) => $val !== null
);
}
@@ -174,8 +170,8 @@ function($val) {
protected function dedupeArrayOfArrays(array $data): array {
$encoded = array_map('json_encode', $data);
$unique = array_values(array_unique($encoded));
- $decoded = array_map(function($item) {
- return json_decode($item, true); },
+ $decoded = array_map(
+ fn($item) => json_decode((string) $item, true),
$unique
);
return $decoded;
diff --git a/Controller/Adminhtml/IndexingManager/Index.php b/Controller/Adminhtml/IndexingManager/Index.php
new file mode 100644
index 000000000..b415cbbcc
--- /dev/null
+++ b/Controller/Adminhtml/IndexingManager/Index.php
@@ -0,0 +1,37 @@
+resultFactory = $context->getResultFactory();
+ }
+
+ /**
+ * @return Page
+ */
+ public function execute()
+ {
+ $breadMain = __('Algolia | Indexing Manager');
+
+ /** @var Page $resultPage */
+ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
+ $resultPage->getConfig()->getTitle()->set($breadMain);
+
+ return $resultPage;
+ }
+}
diff --git a/Controller/Adminhtml/IndexingManager/Reindex.php b/Controller/Adminhtml/IndexingManager/Reindex.php
new file mode 100644
index 000000000..f3214593d
--- /dev/null
+++ b/Controller/Adminhtml/IndexingManager/Reindex.php
@@ -0,0 +1,169 @@
+getRequest()->getParams();
+ $storeIds = !isset($params["store_id"]) || $params["store_id"] === (string) AlgoliaConnector::ALGOLIA_DEFAULT_SCOPE ?
+ array_keys($this->storeManager->getStores()) :
+ [(int) $params["store_id"]];
+
+ $entities = $this->defineEntitiesToIndex($params);
+ $entityIds = $params['selected'] ?? null;
+
+ $this->reindexEntities($entities, $storeIds, $entityIds);
+
+ /** @var Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+
+ return $resultRedirect->setPath($this->defineRedirectPath($params));
+ }
+
+ /**
+ * @return array|string[]
+ */
+ protected function defineEntitiesToIndex(array $params): array
+ {
+ $entities = [];
+ if (isset($params["entity"])) {
+ $entities = $this->isFullIndex($params) ?
+ ['products', 'categories', 'pages'] :
+ [$params["entity"]];
+ } else if ($this->isMassAction($params)) {
+ $entities = match ($params["namespace"]) {
+ 'product_listing' => ['products'],
+ 'cms_page_listing' => ['pages'],
+ default => []
+ };
+ }
+
+ return $entities;
+ }
+
+ /**
+ * @param array $params
+ * @return string
+ */
+ protected function defineRedirectPath(array $params): string
+ {
+ $redirect = '*/*/';
+
+ if (isset($params["redirect"])) {
+ return $params["redirect"];
+ }
+
+ if ($this->isMassAction($params)) {
+ $redirect = match ($params["namespace"]) {
+ 'product_listing' => 'catalog/product/index',
+ 'cms_page_listing' => 'cms/page/index',
+ default => '*/*/'
+ };
+ }
+
+ return $redirect;
+ }
+
+ /**
+ * Defines if all entities need to be reindex
+ *
+ * @param array $params
+ * @return bool
+ */
+ protected function isFullIndex(array $params): bool
+ {
+ return isset($params["entity"]) && $params["entity"] === 'all';
+ }
+
+ /**
+ * Check if the request is coming from a grid (products or pages)
+ *
+ * @param array $params
+ * @return bool
+ */
+ protected function isMassAction(array $params): bool
+ {
+ return isset($params["namespace"]);
+ }
+
+ /**
+ * @param array $entities
+ * @param array|null $storeIds
+ * @param array|null $entityIds
+ * @return void
+ * @throws AlgoliaException
+ * @throws DiagnosticsException
+ * @throws NoSuchEntityException
+ * @throws LocalizedException
+ */
+ protected function reindexEntities(array $entities, ?array $storeIds = null, ?array $entityIds = null): void
+ {
+ foreach ($entities as $entity) {
+ $processor = match ($entity) {
+ 'products' => $this->productBatchQueueProcessor,
+ 'categories' => $this->categoryBatchQueueProcessor,
+ 'pages' => $this->pageBatchQueueProcessor,
+ default => throw new AlgoliaException('Unknown entity to index.'),
+ };
+
+ foreach ($storeIds as $storeId) {
+ $processor->processBatch($storeId, $entityIds);
+ $message = $this->storeNameFetcher->getStoreName($storeId) . " ";
+ $message .= "(" . $this->indexNameFetcher->getIndexName('_' . $entity, $storeId);
+
+ if (!is_null($entityIds)) {
+ $recordLabel = count($entityIds) > 1 ? "records" : "record";
+ $message .= " - " . count($entityIds) . " " . $recordLabel;
+ } else {
+ $message .= " - full reindexing job";
+ }
+
+ if (!$this->configHelper->isQueueActive($storeId)) {
+ $message .= " successfully processed)";
+ } else {
+ $message .= " successfully added to the Algolia indexing queue)";
+ }
+
+ $this->messageManager->addSuccessMessage(htmlentities(__($message)));
+ }
+ }
+ }
+}
diff --git a/Controller/Adminhtml/Landingpage/Save.php b/Controller/Adminhtml/Landingpage/Save.php
index db77242d3..94c0c73e9 100755
--- a/Controller/Adminhtml/Landingpage/Save.php
+++ b/Controller/Adminhtml/Landingpage/Save.php
@@ -106,7 +106,7 @@ public function execute()
if (isset($data['algolia_configuration']) && $data['algolia_configuration'] != $data['configuration']) {
$data['configuration'] = $data['algolia_configuration'];
if ($this->configHelper->isCustomerGroupsEnabled($data['store_id'])) {
- $configuration = json_decode($data['algolia_configuration'], true);
+ $configuration = json_decode((string) $data['algolia_configuration'], true);
if (isset($configuration['price'.$data['price_key']])) {
$priceConfig = $configuration['price'.$data['price_key']];
$customerGroups = $this->customerGroupCollectionFactory->create();
@@ -163,7 +163,7 @@ public function execute()
*/
protected function manageQueryRules(int $landingPageId, array $data): void
{
- $positions = json_decode($data['algolia_merchandising_positions'], true);
+ $positions = json_decode((string) $data['algolia_merchandising_positions'], true);
$stores = [];
if ($data['store_id'] == 0) {
foreach ($this->storeManager->getStores() as $store) {
diff --git a/Controller/Adminhtml/Query/Save.php b/Controller/Adminhtml/Query/Save.php
index 49c346ece..d62dc6ccc 100755
--- a/Controller/Adminhtml/Query/Save.php
+++ b/Controller/Adminhtml/Query/Save.php
@@ -157,7 +157,7 @@ public function execute()
*/
private function manageQueryRules(int $queryId, array $data): void
{
- $positions = json_decode($data['algolia_merchandising_positions'], true);
+ $positions = json_decode((string) $data['algolia_merchandising_positions'], true);
$stores = [];
if ($data['store_id'] == 0) {
$stores = $this->getActiveStores();
diff --git a/Controller/Adminhtml/Reindex/Save.php b/Controller/Adminhtml/Reindex/Save.php
index 3de8e46fc..d6d65aa91 100644
--- a/Controller/Adminhtml/Reindex/Save.php
+++ b/Controller/Adminhtml/Reindex/Save.php
@@ -10,6 +10,7 @@
use Algolia\AlgoliaSearch\Helper\Data as DataHelper;
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
use Algolia\AlgoliaSearch\Service\Product\IndexBuilder as ProductIndexBuilder;
+use Algolia\AlgoliaSearch\Service\Product\RecordBuilder as ProductRecordBuilder;
use Magento\Backend\App\Action\Context;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Controller\ResultFactory;
@@ -27,6 +28,7 @@ public function __construct(
protected StoreManagerInterface $storeManager,
protected DataHelper $dataHelper,
protected ProductHelper $productHelper,
+ protected ProductRecordBuilder $productRecordBuilder,
protected ProductIndexBuilder $productIndexBuilder
) {
parent::__construct($context);
@@ -43,7 +45,7 @@ public function execute()
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('*/*/index');
- $skus = preg_split("/(,|\r\n|\n|\r)/", $this->getRequest()->getParam('skus'));
+ $skus = preg_split("/(,|\r\n|\n|\r)/", (string) $this->getRequest()->getParam('skus'));
$stores = $this->storeManager->getStores();
@@ -147,7 +149,7 @@ protected function checkAndReindex($product, $stores)
try {
$product = $this->productRepository->get($product->getSku(), false, $storeId);
- $this->productHelper->canProductBeReindexed($product, $storeId);
+ $this->productRecordBuilder->canProductBeReindexed($product, $storeId);
} catch (ProductDisabledException $e) {
// Product status is a Website specific attribute
$this->messageManager->addErrorMessage(
diff --git a/Cron/ProcessQueue.php b/Cron/ProcessQueue.php
new file mode 100644
index 000000000..a3af368ef
--- /dev/null
+++ b/Cron/ProcessQueue.php
@@ -0,0 +1,31 @@
+configHelper->isQueueIndexerEnabled() || !$this->configHelper->useBuiltInCron()) {
+ return;
+ }
+
+ if (!$this->algoliaCredentialsManager->checkCredentialsWithSearchOnlyAPIKey()) {
+ $this->algoliaCredentialsManager->displayErrorMessage(self::class);
+
+ return;
+ }
+
+ $this->queue->runCron();
+ }
+}
diff --git a/Exception/InvalidCronException.php b/Exception/InvalidCronException.php
new file mode 100644
index 000000000..1bb09b315
--- /dev/null
+++ b/Exception/InvalidCronException.php
@@ -0,0 +1,7 @@
+objectManager->create('\Magento\CatalogPermissions\Model\ResourceModel\Permission\Index');
+ return $this->objectManager->create(\Magento\CatalogPermissions\Model\ResourceModel\Permission\Index::class);
}
public function getCatalogPermissionsHelper()
{
- return $this->objectManager->create('\Magento\CatalogPermissions\Helper\Data');
+ return $this->objectManager->create(\Magento\CatalogPermissions\Helper\Data::class);
}
public function getCatalogPermissionsConfig()
{
- return $this->objectManager->create('\Magento\CatalogPermissions\App\Config');
+ return $this->objectManager->create(\Magento\CatalogPermissions\App\Config::class);
}
public function getCategoryPermissionsCollection()
diff --git a/Factory/SharedCatalogFactory.php b/Factory/SharedCatalogFactory.php
index faf6188d6..39b348f1c 100644
--- a/Factory/SharedCatalogFactory.php
+++ b/Factory/SharedCatalogFactory.php
@@ -115,7 +115,7 @@ public function getSharedProductItemCollection()
$groups = $this->getSharedCatalogGroups();
foreach ($productItems as $productId => $permissions) {
- $permissions = explode(',', $permissions);
+ $permissions = explode(',', (string) $permissions);
$finalPermissions = [];
foreach ($groups as $groupId) {
$finalPermissions[] = $groupId . '_' . (in_array($groupId, $permissions) ? '1' : '0');
diff --git a/Helper/Adapter/FiltersHelper.php b/Helper/Adapter/FiltersHelper.php
index 571d71989..66d034dd6 100644
--- a/Helper/Adapter/FiltersHelper.php
+++ b/Helper/Adapter/FiltersHelper.php
@@ -103,7 +103,7 @@ public function getLandingPageFilters($storeId)
$landingPageFilter = [];
$landingPage = $this->registry->registry('current_landing_page');
if ($landingPage) {
- $landingPageConfiguration = json_decode($landingPage->getConfiguration(), true);
+ $landingPageConfiguration = json_decode((string) $landingPage->getConfiguration(), true);
$landingPageFilter['facetFilters'] = $this->getFacetFilters($storeId, $landingPageConfiguration);
$landingPageFilter = array_merge(
$landingPageFilter,
@@ -153,7 +153,7 @@ public function getFacetFilters($storeId, $parameters = null)
$facetValues = is_array($parameters[$facet['attribute']]) ?
$parameters[$facet['attribute']] :
- explode('~', $parameters[$facet['attribute']]);
+ explode('~', (string) $parameters[$facet['attribute']]);
// Backward compatibility with native Magento filtering
if (!$this->config->isInstantEnabled($storeId)) {
@@ -172,7 +172,7 @@ public function getFacetFilters($storeId, $parameters = null)
}
if ($facet['type'] === 'conjunctive') {
- foreach ($facetValues as $key => $facetValue) {
+ foreach ($facetValues as $facetValue) {
$facetFilters[] = $facet['attribute'] . ':' . $facetValue;
}
}
diff --git a/Helper/AlgoliaHelper.php b/Helper/AlgoliaHelper.php
old mode 100755
new mode 100644
index dcfa88e60..3d25ef3de
--- a/Helper/AlgoliaHelper.php
+++ b/Helper/AlgoliaHelper.php
@@ -15,7 +15,7 @@
use Magento\Framework\Exception\NoSuchEntityException;
/**
- * @deprecated (will be removed in v3.16.0)
+ * @deprecated (will be removed from the codebase in v3.17.0)
*/
class AlgoliaHelper extends AbstractHelper
{
@@ -297,7 +297,7 @@ public function copyQueryRules(string $fromIndexName, string $toIndexName, ?int
*
* @throws AlgoliaException|NoSuchEntityException
*/
- public function searchRules(string $indexName, array $searchRulesParams = null, ?int $storeId = null)
+ public function searchRules(string $indexName, ?array $searchRulesParams = null, ?int $storeId = null)
{
$indexOptions = $this->indexOptionsBuilder->buildWithEnforcedIndex($indexName, $storeId);
diff --git a/Helper/AnalyticsHelper.php b/Helper/AnalyticsHelper.php
index ba199a358..6a15dcc68 100644
--- a/Helper/AnalyticsHelper.php
+++ b/Helper/AnalyticsHelper.php
@@ -200,7 +200,7 @@ public function getTopHits(array $params): array
*/
public function getTopHitsForSearch($search, array $params): array
{
- return $this->safeFetch(self::ANALYTICS_HITS_PATH . '?search=' . urlencode($search), $params);
+ return $this->safeFetch(self::ANALYTICS_HITS_PATH . '?search=' . urlencode((string) $search), $params);
}
/**
diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php
index 2b33be882..a7d2e237e 100755
--- a/Helper/ConfigHelper.php
+++ b/Helper/ConfigHelper.php
@@ -3,25 +3,26 @@
namespace Algolia\AlgoliaSearch\Helper;
use Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface;
+use Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper;
+use Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper;
use Algolia\AlgoliaSearch\Service\AlgoliaConnector;
-use Magento;
+use Algolia\AlgoliaSearch\Service\Serializer;
use Magento\Cookie\Helper\Cookie as CookieHelper;
+use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
+use Magento\Customer\Model\ResourceModel\Group\Collection as GroupCollection;
use Magento\Directory\Model\Currency as DirCurrency;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\DataObject;
use Magento\Framework\Locale\Currency;
-use Magento\Framework\Serialize\SerializerInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface;
-use Magento\Customer\Model\ResourceModel\Group\Collection as GroupCollection;
class ConfigHelper
{
+ // --- Credentials & Basic Setup --- //
+
public const ENABLE_FRONTEND = 'algoliasearch_credentials/credentials/enable_frontend';
- public const ENABLE_BACKEND = 'algoliasearch_credentials/credentials/enable_backend';
- public const ENABLE_QUERY_SUGGESTIONS_INDEX = 'algoliasearch_credentials/credentials/enable_query_suggestions_index';
- public const ENABLE_PAGES_INDEX = 'algoliasearch_credentials/credentials/enable_pages_index';
public const LOGGING_ENABLED = 'algoliasearch_credentials/credentials/debug';
public const APPLICATION_ID = 'algoliasearch_credentials/credentials/application_id';
public const API_KEY = 'algoliasearch_credentials/credentials/api_key';
@@ -31,38 +32,16 @@ class ConfigHelper
public const ALLOW_COOKIE_BUTTON_SELECTOR = 'algoliasearch_credentials/algolia_cookie_configuration/allow_cookie_button_selector';
public const ALGOLIA_COOKIE_DURATION = 'algoliasearch_credentials/algolia_cookie_configuration/cookie_duration';
-
- public const IS_INSTANT_ENABLED = 'algoliasearch_instant/instant/is_instant_enabled';
- public const REPLACE_CATEGORIES = 'algoliasearch_instant/instant/replace_categories';
- public const INSTANT_SELECTOR = 'algoliasearch_instant/instant/instant_selector';
- public const NUMBER_OF_PRODUCT_RESULTS = 'algoliasearch_instant/instant/number_product_results';
- public const FACETS = 'algoliasearch_instant/instant_facets/facets';
- public const MAX_VALUES_PER_FACET = 'algoliasearch_instant/instant_facets/max_values_per_facet';
- public const SORTING_INDICES = 'algoliasearch_instant/instant_sorts/sorts';
- public const SEARCHBOX_ENABLE = 'algoliasearch_instant/instant_options/instantsearch_searchbox';
- public const SHOW_SUGGESTIONS_NO_RESULTS = 'algoliasearch_instant/instant_options/show_suggestions_on_no_result_page';
- public const XML_ADD_TO_CART_ENABLE = 'algoliasearch_instant/instant_options/add_to_cart_enable';
- public const INFINITE_SCROLL_ENABLE = 'algoliasearch_instant/instant_options/infinite_scroll_enable';
- public const HIDE_PAGINATION = 'algoliasearch_instant/instant_options/hide_pagination';
-
- public const IS_POPUP_ENABLED = 'algoliasearch_autocomplete/autocomplete/is_popup_enabled';
- public const NB_OF_PRODUCTS_SUGGESTIONS = 'algoliasearch_autocomplete/autocomplete/nb_of_products_suggestions';
- public const NB_OF_CATEGORIES_SUGGESTIONS = 'algoliasearch_autocomplete/autocomplete/nb_of_categories_suggestions';
- public const NB_OF_QUERIES_SUGGESTIONS = 'algoliasearch_autocomplete/autocomplete/nb_of_queries_suggestions';
- public const AUTOCOMPLETE_SECTIONS = 'algoliasearch_autocomplete/autocomplete/sections';
- public const EXCLUDED_PAGES = 'algoliasearch_autocomplete/autocomplete/excluded_pages';
- public const MIN_POPULARITY = 'algoliasearch_autocomplete/autocomplete/min_popularity';
- public const MIN_NUMBER_OF_RESULTS = 'algoliasearch_autocomplete/autocomplete/min_number_of_results';
- public const RENDER_TEMPLATE_DIRECTIVES = 'algoliasearch_autocomplete/autocomplete/render_template_directives';
- public const AUTOCOMPLETE_MENU_DEBUG = 'algoliasearch_autocomplete/autocomplete/debug';
- public const AUTOCOMPLETE_DEBOUNCE_MILLISEC = 'algoliasearch_autocomplete/autocomplete/debounce_millisec';
- public const AUTOCOMPLETE_MINIMUM_CHAR_LENGTH = 'algoliasearch_autocomplete/autocomplete/minimum_char_length';
+ // --- Products --- //
public const PRODUCT_ATTRIBUTES = 'algoliasearch_products/products/product_additional_attributes';
public const PRODUCT_CUSTOM_RANKING = 'algoliasearch_products/products/custom_ranking_product_attributes';
public const USE_ADAPTIVE_IMAGE = 'algoliasearch_products/products/use_adaptive_image';
public const ENABLE_VISUAL_MERCHANDISING = 'algoliasearch_products/products/enable_visual_merchandising';
public const CATEGORY_PAGE_ID_ATTRIBUTE_NAME = 'algoliasearch_products/products/category_page_id_attribute_name';
+ public const INCLUDE_NON_VISIBLE_PRODUCTS_IN_INDEX = 'algoliasearch_products/products/include_non_visible_products_in_index';
+
+ // --- Categories --- //
public const CATEGORY_ATTRIBUTES = 'algoliasearch_categories/categories/category_additional_attributes';
public const CATEGORY_CUSTOM_RANKING = 'algoliasearch_categories/categories/custom_ranking_category_attributes';
@@ -70,33 +49,82 @@ class ConfigHelper
public const INDEX_EMPTY_CATEGORIES = 'algoliasearch_categories/categories/index_empty_categories';
public const CATEGORY_SEPARATOR = 'algoliasearch_categories/categories/category_separator';
- public const IS_ACTIVE = 'algoliasearch_queue/queue/active';
- public const NUMBER_OF_JOB_TO_RUN = 'algoliasearch_queue/queue/number_of_job_to_run';
- public const RETRY_LIMIT = 'algoliasearch_queue/queue/number_of_retries';
+ // --- Recommend Products Settings --- //
+
+ public const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled';
+ public const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled';
+ public const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED_ON_CART_PAGE = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled_in_cart_page';
+ public const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED_ON_CART_PAGE = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled_in_cart_page';
+ protected const NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS = 'algoliasearch_recommend/recommend/frequently_bought_together/num_of_frequently_bought_together_products';
+ protected const NUM_OF_RECOMMEND_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/num_of_related_products';
+ protected const IS_REMOVE_RELATED_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/related_product/is_remove_core_related_products_block';
+ protected const IS_REMOVE_UPSELL_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/frequently_bought_together/is_remove_core_upsell_products_block';
+ public const IS_RECOMMEND_TRENDING_ITEMS_ENABLED = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled';
+ protected const IS_RECOMMEND_LOOKING_SIMILAR_ENABLED = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled';
+ protected const NUM_OF_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/num_of_products';
+ protected const NUM_OF_TRENDING_ITEMS = 'algoliasearch_recommend/recommend/trends_item/num_of_trending_items';
+ protected const TREND_ITEMS_FACET_NAME = 'algoliasearch_recommend/recommend/trends_item/facet_name';
+ protected const TREND_ITEMS_FACET_VALUE = 'algoliasearch_recommend/recommend/trends_item/facet_value';
+ public const IS_TREND_ITEMS_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_pdp';
+ public const IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_cart_page';
+ protected const IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER = 'algoliasearch_recommend/recommend/frequently_bought_together/is_addtocart_enabled';
+ protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled';
+ protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM = 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled';
+ protected const IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/is_addtocart_enabled';
+ public const IS_LOOKING_SIMILAR_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_pdp';
+ public const IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_cart_page';
+ protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
+ protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
+ protected const RELATED_PRODUCTS_TITLE = 'algoliasearch_recommend/recommend/related_product/title';
+ protected const TRENDING_ITEMS_TITLE = 'algoliasearch_recommend/recommend/trends_item/title';
+
+ // --- Images --- //
public const XML_PATH_IMAGE_WIDTH = 'algoliasearch_images/image/width';
public const XML_PATH_IMAGE_HEIGHT = 'algoliasearch_images/image/height';
public const XML_PATH_IMAGE_TYPE = 'algoliasearch_images/image/type';
+ // --- Indexing Queue / Cron --- //
+
+ public const IS_ACTIVE = 'algoliasearch_queue/queue/active';
+ public const USE_BUILT_IN_CRON = 'algoliasearch_queue/queue/use_built_in_cron';
+ public const NUMBER_OF_JOB_TO_RUN = 'algoliasearch_queue/queue/number_of_job_to_run';
+ public const RETRY_LIMIT = 'algoliasearch_queue/queue/number_of_retries';
+
+ // --- Indexing Manager --- //
+
+ public const ENABLE_INDEXING = 'algoliasearch_indexing_manager/algolia_indexing/enable_indexing';
+ public const ENABLE_QUERY_SUGGESTIONS_INDEX = 'algoliasearch_indexing_manager/algolia_indexing/enable_query_suggestions_index';
+ public const ENABLE_PAGES_INDEX = 'algoliasearch_indexing_manager/algolia_indexing/enable_pages_index';
+ public const ENABLE_INDEXER_PRODUCTS = 'algoliasearch_indexing_manager/full_indexing/products';
+ public const ENABLE_INDEXER_CATEGORIES = 'algoliasearch_indexing_manager/full_indexing/categories';
+ public const ENABLE_INDEXER_PAGES = 'algoliasearch_indexing_manager/full_indexing/pages';
+ public const ENABLE_INDEXER_SUGGESTIONS = 'algoliasearch_indexing_manager/full_indexing/suggestions';
+ public const ENABLE_INDEXER_ADDITIONAL_SECTIONS = 'algoliasearch_indexing_manager/full_indexing/additional_sections';
+ public const ENABLE_INDEXER_DELETE_PRODUCTS = 'algoliasearch_indexing_manager/full_indexing/delete_products';
+ public const ENABLE_INDEXER_QUEUE = 'algoliasearch_indexing_manager/full_indexing/queue';
+
+ // --- Click & Conversion Analytics --- //
+
public const CC_ANALYTICS_ENABLE = 'algoliasearch_cc_analytics/cc_analytics_group/enable';
public const CC_ANALYTICS_IS_SELECTOR = 'algoliasearch_cc_analytics/cc_analytics_group/is_selector';
public const CC_CONVERSION_ANALYTICS_MODE = 'algoliasearch_cc_analytics/cc_analytics_group/conversion_analytics_mode';
public const CC_ADD_TO_CART_SELECTOR = 'algoliasearch_cc_analytics/cc_analytics_group/add_to_cart_selector';
- public const COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
+
+ // --- Google Analytics --- //
public const GA_ENABLE = 'algoliasearch_analytics/analytics_group/enable';
public const GA_DELAY = 'algoliasearch_analytics/analytics_group/delay';
public const GA_TRIGGER_ON_UI_INTERACTION = 'algoliasearch_analytics/analytics_group/trigger_on_ui_interaction';
public const GA_PUSH_INITIAL_SEARCH = 'algoliasearch_analytics/analytics_group/push_initial_search';
+ // --- Advanced --- //
+
public const REMOVE_IF_NO_RESULT = 'algoliasearch_advanced/advanced/remove_words_if_no_result';
public const PARTIAL_UPDATES = 'algoliasearch_advanced/advanced/partial_update';
public const CUSTOMER_GROUPS_ENABLE = 'algoliasearch_advanced/advanced/customer_groups_enable';
public const REMOVE_PUB_DIR_IN_URL = 'algoliasearch_advanced/advanced/remove_pub_dir_in_url';
- public const MAKE_SEO_REQUEST = 'algoliasearch_advanced/advanced/make_seo_request';
public const REMOVE_BRANDING = 'algoliasearch_advanced/advanced/remove_branding';
- public const AUTOCOMPLETE_SELECTOR = 'algoliasearch_autocomplete/autocomplete/autocomplete_selector';
- public const INCLUDE_NON_VISIBLE_PRODUCTS_IN_INDEX = 'algoliasearch_products/products/include_non_visible_products_in_index';
public const IDX_PRODUCT_ON_CAT_PRODUCTS_UPD = 'algoliasearch_advanced/advanced/index_product_on_category_products_update';
public const PREVENT_BACKEND_RENDERING = 'algoliasearch_advanced/advanced/prevent_backend_rendering';
public const PREVENT_BACKEND_RENDERING_DISPLAY_MODE =
@@ -109,13 +137,16 @@ class ConfigHelper
public const CONNECTION_TIMEOUT = 'algoliasearch_advanced/advanced/connection_timeout';
public const READ_TIMEOUT = 'algoliasearch_advanced/advanced/read_timeout';
public const WRITE_TIMEOUT = 'algoliasearch_advanced/advanced/write_timeout';
+ protected const FORWARD_TO_REPLICAS = 'algoliasearch_advanced/advanced/forward_to_replicas';
public const AUTO_PRICE_INDEXING_ENABLED = 'algoliasearch_advanced/advanced/auto_price_indexing';
-
public const PROFILER_ENABLED = 'algoliasearch_advanced/advanced/enable_profiler';
- public const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
+ // Indexing Queue advanced settings
+ public const ENHANCED_QUEUE_ARCHIVE = 'algoliasearch_advanced/queue/enhanced_archive';
+ public const NUMBER_OF_ELEMENT_BY_PAGE = 'algoliasearch_advanced/queue/number_of_element_by_page';
+ public const ARCHIVE_LOG_CLEAR_LIMIT = 'algoliasearch_advanced/queue/archive_clear_limit';
- public const USE_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
+ // --- Extra index settings --- //
public const EXTRA_SETTINGS_PRODUCTS = 'algoliasearch_extra_settings/extra_settings/products_extra_settings';
public const EXTRA_SETTINGS_CATEGORIES = 'algoliasearch_extra_settings/extra_settings/categories_extra_settings';
@@ -123,146 +154,128 @@ class ConfigHelper
public const EXTRA_SETTINGS_SUGGESTIONS = 'algoliasearch_extra_settings/extra_settings/suggestions_extra_settings';
public const EXTRA_SETTINGS_ADDITIONAL_SECTIONS =
'algoliasearch_extra_settings/extra_settings/additional_sections_extra_settings';
- public const MAGENTO_DEFAULT_CACHE_TIME = 'system/full_page_cache/ttl';
- public const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled';
- public const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled';
- public const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED_ON_CART_PAGE = 'algoliasearch_recommend/recommend/frequently_bought_together/is_frequently_bought_together_enabled_in_cart_page';
- public const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED_ON_CART_PAGE = 'algoliasearch_recommend/recommend/related_product/is_related_products_enabled_in_cart_page';
- protected const NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS = 'algoliasearch_recommend/recommend/frequently_bought_together/num_of_frequently_bought_together_products';
- protected const NUM_OF_RECOMMEND_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/num_of_related_products';
- protected const IS_REMOVE_RELATED_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/related_product/is_remove_core_related_products_block';
- protected const IS_REMOVE_UPSELL_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/frequently_bought_together/is_remove_core_upsell_products_block';
- public const IS_RECOMMEND_TRENDING_ITEMS_ENABLED = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled';
- protected const IS_RECOMMEND_LOOKING_SIMILAR_ENABLED = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled';
- protected const NUM_OF_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/num_of_products';
- protected const NUM_OF_TRENDING_ITEMS = 'algoliasearch_recommend/recommend/trends_item/num_of_trending_items';
- protected const TREND_ITEMS_FACET_NAME = 'algoliasearch_recommend/recommend/trends_item/facet_name';
- protected const TREND_ITEMS_FACET_VALUE = 'algoliasearch_recommend/recommend/trends_item/facet_value';
- public const IS_TREND_ITEMS_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_pdp';
- public const IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled_on_cart_page';
- protected const IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER = 'algoliasearch_recommend/recommend/frequently_bought_together/is_addtocart_enabled';
- protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled';
- protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM = 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled';
- protected const IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/is_addtocart_enabled';
- public const IS_LOOKING_SIMILAR_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_pdp';
- public const IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_cart_page';
- protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
- public const LEGACY_USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
- protected const AUTOCOMPLETE_KEYBORAD_NAVIAGATION = 'algoliasearch_autocomplete/autocomplete/navigator';
- protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
- protected const RELATED_PRODUCTS_TITLE = 'algoliasearch_recommend/recommend/related_product/title';
- protected const TRENDING_ITEMS_TITLE = 'algoliasearch_recommend/recommend/trends_item/title';
- // Indexing Queue Advanced settings
- public const ENHANCED_QUEUE_ARCHIVE = 'algoliasearch_advanced/queue/enhanced_archive';
- public const NUMBER_OF_ELEMENT_BY_PAGE = 'algoliasearch_advanced/queue/number_of_element_by_page';
- public const ARCHIVE_LOG_CLEAR_LIMIT = 'algoliasearch_advanced/queue/archive_clear_limit';
+ // --- Magento Core --- //
+
+ public const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
+ public const USE_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
+ public const MAGENTO_DEFAULT_CACHE_TIME = 'system/full_page_cache/ttl';
+ public const COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
public function __construct(
- protected Magento\Framework\App\Config\ScopeConfigInterface $configInterface,
- protected Magento\Framework\App\Config\Storage\WriterInterface $configWriter,
- protected StoreManagerInterface $storeManager,
- protected Currency $currency,
- protected DirCurrency $dirCurrency,
- protected DirectoryList $directoryList,
- protected Magento\Framework\Module\ResourceInterface $moduleResource,
- protected Magento\Framework\App\ProductMetadataInterface $productMetadata,
- protected Magento\Framework\Event\ManagerInterface $eventManager,
- protected SerializerInterface $serializer,
- protected GroupCollection $groupCollection,
- protected GroupExcludedWebsiteRepositoryInterface $groupExcludedWebsiteRepository,
- protected CookieHelper $cookieHelper,
+ protected \Magento\Framework\App\Config\ScopeConfigInterface $configInterface,
+ protected \Magento\Framework\App\Config\Storage\WriterInterface $configWriter,
+ protected StoreManagerInterface $storeManager,
+ protected Currency $currency,
+ protected DirCurrency $dirCurrency,
+ protected DirectoryList $directoryList,
+ protected \Magento\Framework\Module\ResourceInterface $moduleResource,
+ protected \Magento\Framework\App\ProductMetadataInterface $productMetadata,
+ protected \Magento\Framework\Event\ManagerInterface $eventManager,
+ protected Serializer $serializer,
+ protected GroupCollection $groupCollection,
+ protected GroupExcludedWebsiteRepositoryInterface $groupExcludedWebsiteRepository,
+ protected CookieHelper $cookieHelper,
+ protected AutocompleteHelper $autocompleteConfig,
+ protected InstantSearchHelper $instantSearchConfig
)
{}
+ // --- Credentials & Basic Setup --- //
/**
* @param $storeId
* @return bool
+ * @deprecated Use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager instead
*/
- public function showCatsNotIncludedInNavigation($storeId = null)
+ public function credentialsAreConfigured($storeId = null): bool
{
- return $this->configInterface->isSetFlag(
- self::SHOW_CATS_NOT_INCLUDED_IN_NAV,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->getApplicationID($storeId) &&
+ $this->getAPIKey($storeId) &&
+ $this->getSearchOnlyAPIKey($storeId);
}
/**
* @param $storeId
- * @return bool
+ * @return mixed'
*/
- public function shouldIndexEmptyCategories($storeId = null)
+ public function getApplicationID($storeId = null)
{
- return $this->configInterface->isSetFlag(self::INDEX_EMPTY_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(self::APPLICATION_ID, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * @return string
+ * @param $storeId
+ * @return mixed
*/
- public function getMagentoVersion()
+ public function getAPIKey($storeId = null)
{
- return $this->productMetadata->getVersion();
+ return $this->configInterface->getValue(self::API_KEY, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * @return string
+ * @param $storeId
+ * @return mixed
*/
- public function getMagentoEdition()
+ public function getSearchOnlyAPIKey($storeId = null)
{
- return $this->productMetadata->getEdition();
+ return $this->configInterface->getValue(self::SEARCH_ONLY_API_KEY, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * @return false|string
+ * @param int|null $storeId
+ * @return string
*/
- public function getExtensionVersion()
+ public function getIndexPrefix(?int $storeId = null): string
{
- return $this->moduleResource->getDbVersion('Algolia_AlgoliaSearch');
+ return (string) $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isDefaultSelector($storeId = null)
+ public function isEnabledFrontEnd($storeId = null): bool
{
- return '.algolia-search-input' === $this->getAutocompleteSelector($storeId);
+ return $this->configInterface->isSetFlag(self::ENABLE_FRONTEND, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return bool
*/
- public function getAutocompleteSelector($storeId = null)
+ public function isLoggingEnabled($storeId = null): bool
{
- return $this->configInterface->getValue(self::AUTOCOMPLETE_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::LOGGING_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * Returns config flag
- *
- * @param $storeId
- * @return bool
+ * Used for front end search API key generation
+ * @param $groupId
+ * @return array
*/
- public function includeNonVisibleProductsInIndex($storeId = null): bool
+ public function getAttributesToFilter($groupId)
{
- return $this->configInterface->isSetFlag(
- self::INCLUDE_NON_VISIBLE_PRODUCTS_IN_INDEX,
- ScopeInterface::SCOPE_STORE,
- $storeId
+ $transport = new DataObject();
+ $this->eventManager->dispatch(
+ 'algolia_get_attributes_to_filter',
+ ['filter_object' => $transport, 'customer_group_id' => $groupId]
);
+ $attributes = $transport->getData();
+ $attributes = array_unique($attributes);
+ $attributes = array_values($attributes);
+ return count($attributes) ? ['filters' => implode(' AND ', $attributes)] : [];
}
+ // Algolia Cookie Configuration
/**
* @param $storeId
* @return mixed
*/
- public function indexProductOnCategoryProductsUpdate($storeId = null)
+ public function getDefaultConsentCookieName($storeId = null)
{
return $this->configInterface->getValue(
- self::IDX_PRODUCT_ON_CAT_PRODUCTS_UPD,
+ self::COOKIE_DEFAULT_CONSENT_COOKIE_NAME,
ScopeInterface::SCOPE_STORE,
$storeId
);
@@ -270,12 +283,12 @@ public function indexProductOnCategoryProductsUpdate($storeId = null)
/**
* @param $storeId
- * @return int
+ * @return mixed
*/
- public function getNumberOfQueriesSuggestions($storeId = null)
+ public function getAllowCookieButtonSelector($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NB_OF_QUERIES_SUGGESTIONS,
+ return $this->configInterface->getValue(
+ self::ALLOW_COOKIE_BUTTON_SELECTOR,
ScopeInterface::SCOPE_STORE,
$storeId
);
@@ -283,438 +296,572 @@ public function getNumberOfQueriesSuggestions($storeId = null)
/**
* @param $storeId
- * @return int
+ * @return mixed
*/
- public function getNumberOfProductsSuggestions($storeId = null)
+ public function getAlgoliaCookieDuration($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NB_OF_PRODUCTS_SUGGESTIONS,
+ return $this->configInterface->getValue(
+ self::ALGOLIA_COOKIE_DURATION,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
+ // --- Products --- //
+
/**
* @param $storeId
- * @return int
+ * @return array
*/
- public function getNumberOfCategoriesSuggestions($storeId = null)
+ public function getProductAdditionalAttributes($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NB_OF_CATEGORIES_SUGGESTIONS,
+ $attributes = $this->serializer->unserialize($this->configInterface->getValue(
+ self::PRODUCT_ATTRIBUTES,
ScopeInterface::SCOPE_STORE,
$storeId
- );
+ ));
+
+ $facets = $this->serializer->unserialize($this->configInterface->getValue(
+ self::FACETS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ $attributes = $this->addIndexableAttributes($attributes, $facets, '0');
+
+ $sorts = $this->serializer->unserialize($this->configInterface->getValue(
+ self::SORTING_INDICES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ $attributes = $this->addIndexableAttributes($attributes, $sorts, '0');
+
+ $customRankings = $this->serializer->unserialize($this->configInterface->getValue(
+ self::PRODUCT_CUSTOM_RANKING,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ $customRankings = $customRankings ?: [];
+ $customRankings = array_filter($customRankings, fn($customRanking) => $customRanking['attribute'] !== 'custom_attribute');
+ $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0');
+ if (is_array($attributes)) {
+ return $attributes;
+ }
+ return [];
}
/**
- * @param $storeId
- * @return bool
+ * @param $attributes
+ * @param $addedAttributes
+ * @param $searchable
+ * @param $retrievable
+ * @param $indexNoValue
+ * @return mixed
*/
- public function isEnabledFrontEnd($storeId = null)
- {
- return $this->configInterface->isSetFlag(self::ENABLE_FRONTEND, ScopeInterface::SCOPE_STORE, $storeId);
+ protected function addIndexableAttributes(
+ $attributes,
+ $addedAttributes,
+ $searchable = '1',
+ $retrievable = '1',
+ $indexNoValue = '1'
+ ) {
+ foreach ((array)$addedAttributes as $addedAttribute) {
+ foreach ((array)$attributes as $attribute) {
+ if ($addedAttribute['attribute'] === $attribute['attribute']) {
+ continue 2;
+ }
+ }
+ $attributes[] = [
+ 'attribute' => $addedAttribute['attribute'],
+ 'searchable' => $searchable,
+ 'retrievable' => $retrievable,
+ 'index_no_value' => $indexNoValue,
+ ];
+ }
+ return $attributes;
}
/**
* @param $storeId
- * @return bool
+ * @return array
*/
- public function isEnabledBackend($storeId = null)
+ public function getProductCustomRanking($storeId = null)
{
- return $this->configInterface->isSetFlag(self::ENABLE_BACKEND, ScopeInterface::SCOPE_STORE, $storeId);
+ $attrs = $this->serializer->unserialize($this->getRawProductCustomRanking($storeId));
+ if (is_array($attrs)) {
+ return $attrs;
+ }
+ return [];
}
/**
* @param $storeId
- * @return bool
+ * @return mixed
*/
- public function makeSeoRequest($storeId = null)
+ public function getRawProductCustomRanking($storeId = null)
{
- return $this->configInterface->isSetFlag(self::MAKE_SEO_REQUEST, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::PRODUCT_CUSTOM_RANKING,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
* @return bool
*/
- public function isLoggingEnabled($storeId = null): bool
+ public function useAdaptiveImage($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::LOGGING_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::USE_ADAPTIVE_IMAGE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isProfilerEnabled($storeId = null): bool
+ public function isVisualMerchEnabled($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::PROFILER_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::ENABLE_VISUAL_MERCHANDISING, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return bool
+ * @return string
*/
- public function getShowOutOfStock($storeId = null)
+ public function getCategoryPageIdAttributeName($storeId = null): string
{
- return $this->configInterface->isSetFlag(self::SHOW_OUT_OF_STOCK, ScopeInterface::SCOPE_STORE, $storeId);
+ return (string) $this->configInterface->getValue(self::CATEGORY_PAGE_ID_ATTRIBUTE_NAME, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
+ * Returns config flag
+ *
* @param $storeId
* @return bool
*/
- public function useSecureUrlsInFrontend($storeId = null)
+ public function includeNonVisibleProductsInIndex($storeId = null): bool
{
return $this->configInterface->isSetFlag(
- self::USE_SECURE_IN_FRONTEND,
+ self::INCLUDE_NON_VISIBLE_PRODUCTS_IN_INDEX,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
/**
- * @param $storeId
- * @return int
+ * NOTE: This method is currently only used in integration tests and was removed from the general implementation
+ * TODO: Evaluate use cases with product permissions where we may need to restore this functionality
+ * @param $groupId
+ * @return array
*/
- public function getImageWidth($storeId = null)
+ public function getAttributesToRetrieve($groupId)
{
- $imageWidth = $this->configInterface->getValue(
- self::XML_PATH_IMAGE_WIDTH,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
-
- if (!$imageWidth) {
- return 265;
+ if (false === $this->isCustomerGroupsEnabled()) {
+ return [];
}
-
- return (int)$imageWidth;
- }
-
- /**
- * @param $storeId
- * @return int
- */
- public function getImageHeight($storeId = null)
- {
- $imageHeight = $this->configInterface->getValue(
- self::XML_PATH_IMAGE_HEIGHT,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
-
- if (!$imageHeight) {
- return 265;
+ $attributes = [];
+ foreach ($this->getProductAdditionalAttributes() as $attribute) {
+ if ($attribute['attribute'] !== 'price' && $attribute['retrievable'] === '1') {
+ $attributes[] = $attribute['attribute'];
+ }
}
-
- return (int)$imageHeight;
- }
-
- /**
- * @param $storeId
- * @return mixed
- */
- public function getImageType($storeId = null)
- {
- return $this->configInterface->getValue(self::XML_PATH_IMAGE_TYPE, ScopeInterface::SCOPE_STORE, $storeId);
+ foreach ($this->getCategoryAdditionalAttributes() as $attribute) {
+ if ($attribute['retrievable'] === '1') {
+ $attributes[] = $attribute['attribute'];
+ }
+ }
+ $attributes = array_merge($attributes, [
+ AlgoliaConnector::ALGOLIA_API_OBJECT_ID,
+ 'name',
+ 'url',
+ 'visibility_search',
+ 'visibility_catalog',
+ 'categories',
+ 'categories_without_path',
+ 'thumbnail_url',
+ 'image_url',
+ 'images_data',
+ 'in_stock',
+ 'type_id',
+ 'value',
+ 'query', # suggestions
+ 'path', # categories
+ 'default_bundle_options',
+ ]);
+ $currencies = $this->dirCurrency->getConfigAllowCurrencies();
+ foreach ($currencies as $currency) {
+ $attributes[] = 'price.' . $currency . '.default';
+ $attributes[] = 'price.' . $currency . '.default_tier';
+ $attributes[] = 'price.' . $currency . '.default_max';
+ $attributes[] = 'price.' . $currency . '.default_formated';
+ $attributes[] = 'price.' . $currency . '.default_original_formated';
+ $attributes[] = 'price.' . $currency . '.default_tier_formated';
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId;
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_tier';
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_max';
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_formated';
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_tier_formated';
+ $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_original_formated';
+ $attributes[] = 'price.' . $currency . '.special_from_date';
+ $attributes[] = 'price.' . $currency . '.special_to_date';
+ }
+ $transport = new DataObject($attributes);
+ $this->eventManager->dispatch('algolia_get_retrievable_attributes', ['attributes' => $transport]);
+ $attributes = $transport->getData();
+ $attributes = array_unique($attributes);
+ $attributes = array_values($attributes);
+ return ['attributesToRetrieve' => $attributes];
}
/**
- * @param $storeId
+ * @param int|null $storeId
* @return bool
*/
- public function shouldRemovePubDirectory($storeId = null)
+ public function useVirtualReplica(?int $storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::REMOVE_PUB_DIR_IN_URL, ScopeInterface::SCOPE_STORE, $storeId);
+ return (bool) count(array_filter(
+ $this->getSorting($storeId),
+ fn($sort) => $sort[ReplicaManagerInterface::SORT_KEY_VIRTUAL_REPLICA]
+ ));
}
+ // --- Categories --- //
/**
* @param $storeId
- * @return bool
+ * @return array
*/
- public function isPartialUpdateEnabled($storeId = null)
+ public function getCategoryAdditionalAttributes($storeId = null)
{
- return $this->configInterface->isSetFlag(self::PARTIAL_UPDATES, ScopeInterface::SCOPE_STORE, $storeId);
+ $attributes = $this->serializer->unserialize($this->configInterface->getValue(
+ self::CATEGORY_ATTRIBUTES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ $customRankings = $this->serializer->unserialize($this->configInterface->getValue(
+ self::CATEGORY_CUSTOM_RANKING,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ $customRankings = $customRankings ?: [];
+ $customRankings = array_filter($customRankings, fn($customRanking) => $customRanking['attribute'] !== 'custom_attribute');
+ $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0');
+ if (is_array($attributes)) {
+ return $attributes;
+ }
+ return [];
}
/**
* @param $storeId
* @return array
*/
- public function getAutocompleteSections($storeId = null)
+ public function getCategoryCustomRanking($storeId = null): array
{
- $attrs = $this->unserialize($this->configInterface->getValue(
- self::AUTOCOMPLETE_SECTIONS,
+ $attrs = $this->serializer->unserialize($this->configInterface->getValue(
+ self::CATEGORY_CUSTOM_RANKING,
ScopeInterface::SCOPE_STORE,
$storeId
));
-
if (is_array($attrs)) {
- return array_values($attrs);
+ return $attrs;
}
-
return [];
}
- protected function serialize(array $value): string {
- return $this->serializer->serialize($value) ?: '';
- }
-
/**
- * @param $value
- * @return array|bool|float|int|mixed|string|null
+ * @param $storeId
+ * @return bool
*/
- protected function unserialize($value)
+ public function showCatsNotIncludedInNavigation($storeId = null)
{
- if (false === $value || null === $value || '' === $value) {
- return false;
- }
- $unserialized = json_decode($value, true);
- if (json_last_error() === JSON_ERROR_NONE) {
- return $unserialized;
- }
- return $this->serializer->unserialize($value);
+ return $this->configInterface->isSetFlag(
+ self::SHOW_CATS_NOT_INCLUDED_IN_NAV,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
- * @return int
+ * @return bool
*/
- public function getMinPopularity($storeId = null)
+ public function shouldIndexEmptyCategories($storeId = null): bool
{
- return (int)$this->configInterface->getValue(self::MIN_POPULARITY, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::INDEX_EMPTY_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return int
+ * @return string
*/
- public function getMinNumberOfResults($storeId = null)
+ public function getCategorySeparator($storeId = null): string
{
- return (int)$this->configInterface->getValue(self::MIN_NUMBER_OF_RESULTS, ScopeInterface::SCOPE_STORE, $storeId);
+ return (string) $this->configInterface->getValue(self::CATEGORY_SEPARATOR, ScopeInterface::SCOPE_STORE, $storeId);
}
+ // --- Recommend Product Settings --- //
+
/**
* @param $storeId
* @return bool
*/
- public function isAddToCartEnable($storeId = null)
+ public function isRecommendFrequentlyBroughtTogetherEnabled($storeId = null): bool
{
- return $this->configInterface->isSetFlag(
- self::XML_ADD_TO_CART_ENABLE,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->isSetFlag(self::IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isInfiniteScrollEnabled($storeId = null)
+ public function isRecommendRelatedProductsEnabled($storeId = null): bool
{
- return $this->isInstantEnabled($storeId)
- && $this->configInterface->isSetFlag(self::INFINITE_SCROLL_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_RECOMMEND_RELATED_PRODUCTS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function hidePaginationInInstantSearchPage($storeId = null)
+ public function isRecommendFrequentlyBroughtTogetherEnabledOnCartPage($storeId = null): bool
{
- return $this->isInstantEnabled($storeId)
- && $this->configInterface->isSetFlag(self::HIDE_PAGINATION, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED_ON_CART_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isInstantSearchBoxEnabled($storeId = null)
+ public function isRecommendRelatedProductsEnabledOnCartPage($storeId = null): bool
{
- return $this->isInstantEnabled($storeId)
- && $this->configInterface->isSetFlag(self::SEARCHBOX_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_RECOMMEND_RELATED_PRODUCTS_ENABLED_ON_CART_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isInstantEnabled($storeId = null)
+ public function isRemoveCoreRelatedProductsBlock($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_INSTANT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_REMOVE_RELATED_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isRemoveBranding($storeId = null)
+ public function isRemoveUpsellProductsBlock($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::REMOVE_BRANDING, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_REMOVE_UPSELL_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return int
*/
- public function getMaxValuesPerFacet($storeId = null)
+ public function getNumberOfRelatedProducts($storeId = null): int
{
- return (int)$this->configInterface->getValue(self::MAX_VALUES_PER_FACET, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int) $this->configInterface->getValue(
+ self::NUM_OF_RECOMMEND_RELATED_PRODUCTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
* @return int
*/
- public function getNumberOfElementByPage($storeId = null)
+ public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null): int
{
- return (int)$this->configInterface->getValue(self::NUMBER_OF_ELEMENT_BY_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int) $this->configInterface->getValue(
+ self::NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
- * @param $storeId
- * @return mixed
+ * @param int $storeId
+ * @return int
*/
- public function getNumberOfJobToRun($storeId = null)
+ public function isRecommendTrendingItemsEnabled($storeId = null)
{
- $nbJobs = (int)$this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
-
- return max($nbJobs, 1);
+ return (int)$this->configInterface->getValue(
+ self::IS_RECOMMEND_TRENDING_ITEMS_ENABLED,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
* @return int
*/
- public function getRetryLimit($storeId = null)
+ public function getNumberOfTrendingItems($storeId = null): int
{
- return (int)$this->configInterface->getValue(self::RETRY_LIMIT, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int) $this->configInterface->getValue(
+ self::NUM_OF_TRENDING_ITEMS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
+ * Returns number of looking similar products to display
+ *
* @param $storeId
- * @return bool
+ * @return int
*/
- public function isQueueActive($storeId = null)
+ public function getNumberOfLookingSimilar($storeId = null): int
{
- return $this->configInterface->isSetFlag(self::IS_ACTIVE, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int) $this->configInterface->getValue(
+ self::NUM_OF_LOOKING_SIMILAR,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
- * @return bool
+ * @return mixed
*/
- public function isEnhancedQueueArchiveEnabled($storeId = null)
+ public function getTrendingItemsFacetName($storeId = null)
{
- return $this->configInterface->isSetFlag(self::ENHANCED_QUEUE_ARCHIVE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::TREND_ITEMS_FACET_NAME,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
* @return mixed
*/
- public function getRemoveWordsIfNoResult($storeId = null)
+ public function getTrendingItemsFacetValue($storeId = null)
{
- return $this->configInterface->getValue(self::REMOVE_IF_NO_RESULT, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::TREND_ITEMS_FACET_VALUE,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
+ * Determines whether Looking Similar enabled (for widgets))
+ *
* @param $storeId
* @return int
*/
- public function getNumberOfProductResults($storeId = null)
+ public function isRecommendLookingSimilarEnabled($storeId = null)
{
return (int)$this->configInterface->getValue(
- self::NUMBER_OF_PRODUCT_RESULTS,
+ self::IS_RECOMMEND_LOOKING_SIMILAR_ENABLED,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
/**
+ * Determines whether Looking Similar enabled on PDP
+ *
* @param $storeId
- * @return bool
+ * @return int
*/
- public function replaceCategories($storeId = null)
+ public function isLookingSimilarEnabledInPDP($storeId = null)
{
- return $this->configInterface->isSetFlag(self::REPLACE_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int)$this->configInterface->getValue(
+ self::IS_LOOKING_SIMILAR_ENABLED_IN_PDP,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
- /**
- * @param $storeId
- * @return bool
- */
- public function isAutoCompleteEnabled($storeId = null)
+ public function getLookingSimilarTitle($storeId = null)
{
- return $this->configInterface->isSetFlag(self::IS_POPUP_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::LOOKING_SIMILAR_TITLE,
+ ScopeInterface::SCOPE_STORE, $storeId
+ );
}
/**
* @param $storeId
- * @return bool
+ * @return int
*/
- public function isRecommendFrequentlyBroughtTogetherEnabled($storeId = null)
+ public function isLookingSimilarEnabledInShoppingCart($storeId = null)
{
- return $this->configInterface->isSetFlag(self::IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int)$this->configInterface->getValue(
+ self::IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
- * @return bool
+ * @return int
*/
- public function isRecommendRelatedProductsEnabled($storeId = null)
+ public function isTrendItemsEnabledInPDP($storeId = null)
{
- return $this->configInterface->isSetFlag(self::IS_RECOMMEND_RELATED_PRODUCTS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int)$this->configInterface->getValue(
+ self::IS_TREND_ITEMS_ENABLED_IN_PDP,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
- * @return bool
+ * @return int
*/
- public function isRecommendFrequentlyBroughtTogetherEnabledOnCartPage($storeId = null)
+ public function isTrendItemsEnabledInShoppingCart($storeId = null)
{
- return $this->configInterface->isSetFlag(self::IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED_ON_CART_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
+ return (int)$this->configInterface->getValue(
+ self::IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
* @param $storeId
* @return bool
*/
- public function isRecommendRelatedProductsEnabledOnCartPage($storeId = null)
+ public function isAddToCartEnabledInFrequentlyBoughtTogether($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_RECOMMEND_RELATED_PRODUCTS_ENABLED_ON_CART_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isRemoveCoreRelatedProductsBlock($storeId = null)
+ public function isAddToCartEnabledInRelatedProducts($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_REMOVE_RELATED_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isRemoveUpsellProductsBlock($storeId = null)
+ public function isAddToCartEnabledInTrendsItem($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_REMOVE_UPSELL_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
+ * Determines whether add to cart is enabled in Looking Similar
+ *
* @param $storeId
- * @return int
+ * @return bool
*/
- public function getNumberOfRelatedProducts($storeId = null)
+ public function isAddToCartEnabledInLookingSimilar($storeId = null): bool
{
- return (int)$this->configInterface->getValue(
- self::NUM_OF_RECOMMEND_RELATED_PRODUCTS,
+ return $this->configInterface->isSetFlag(
+ self::IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR,
ScopeInterface::SCOPE_STORE,
$storeId
);
@@ -722,291 +869,254 @@ public function getNumberOfRelatedProducts($storeId = null)
/**
* @param $storeId
- * @return int
+ * @return string
*/
- public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null)
+ public function getFBTTitle($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->getValue(self::FREQUENTLY_BOUGHT_TOGETHER_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * @param int $storeId
- * @return int
- */
- public function isRecommendTrendingItemsEnabled($storeId = null)
+ * @param $storeId
+ * @return string
+ */
+ public function getRelatedProductsTitle($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::IS_RECOMMEND_TRENDING_ITEMS_ENABLED,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->getValue(self::RELATED_PRODUCTS_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return int
+ * @return string
*/
- public function getNumberOfTrendingItems($storeId = null)
+ public function getTrendingItemsTitle($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NUM_OF_TRENDING_ITEMS,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->getValue(self::TRENDING_ITEMS_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
}
+ // --- Images --- //
+
/**
- * Returns number of looking similar products to display
- *
* @param $storeId
* @return int
*/
- public function getNumberOfLookingSimilar($storeId = null)
+ public function getImageWidth($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::NUM_OF_LOOKING_SIMILAR,
+ $imageWidth = $this->configInterface->getValue(
+ self::XML_PATH_IMAGE_WIDTH,
ScopeInterface::SCOPE_STORE,
$storeId
);
+
+ if (!$imageWidth) {
+ return 265;
+ }
+
+ return (int)$imageWidth;
}
/**
* @param $storeId
- * @return mixed
+ * @return int
*/
- public function getTrendingItemsFacetName($storeId = null)
+ public function getImageHeight($storeId = null)
{
- return $this->configInterface->getValue(
- self::TREND_ITEMS_FACET_NAME,
+ $imageHeight = $this->configInterface->getValue(
+ self::XML_PATH_IMAGE_HEIGHT,
ScopeInterface::SCOPE_STORE,
$storeId
);
+
+ if (!$imageHeight) {
+ return 265;
+ }
+
+ return (int)$imageHeight;
}
/**
* @param $storeId
* @return mixed
*/
- public function getTrendingItemsFacetValue($storeId = null)
+ public function getImageType($storeId = null)
{
- return $this->configInterface->getValue(
- self::TREND_ITEMS_FACET_VALUE,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->getValue(self::XML_PATH_IMAGE_TYPE, ScopeInterface::SCOPE_STORE, $storeId);
}
- /**
- * Determines whether Looking Similar enabled (for widgets))
- *
- * @param $storeId
- * @return int
- */
- public function isRecommendLookingSimilarEnabled($storeId = null)
- {
- return (int)$this->configInterface->getValue(
- self::IS_RECOMMEND_LOOKING_SIMILAR_ENABLED,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
- }
+ // --- Indexing Queue / Cron --- //
/**
- * Determines whether Looking Similar enabled on PDP
- *
* @param $storeId
- * @return int
+ * @return mixed
*/
- public function isLookingSimilarEnabledInPDP($storeId = null)
+ public function getNumberOfJobToRun($storeId = null): int
{
- return (int)$this->configInterface->getValue(
- self::IS_LOOKING_SIMILAR_ENABLED_IN_PDP,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
- }
+ $nbJobs = (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
- public function getLookingSimilarTitle($storeId = null)
- {
- return $this->configInterface->getValue(
- self::LOOKING_SIMILAR_TITLE,
- ScopeInterface::SCOPE_STORE, $storeId
- );
+ return (int) max($nbJobs, 1);
}
/**
* @param $storeId
* @return int
*/
- public function isLookingSimilarEnabledInShoppingCart($storeId = null)
+ public function getRetryLimit($storeId = null): int
{
- return (int)$this->configInterface->getValue(
- self::IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return (int) $this->configInterface->getValue(self::RETRY_LIMIT, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return int
+ * @return bool
*/
- public function isTrendItemsEnabledInPDP($storeId = null)
+ public function isQueueActive($storeId = null): bool
{
- return (int)$this->configInterface->getValue(
- self::IS_TREND_ITEMS_ENABLED_IN_PDP,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->isSetFlag(self::IS_ACTIVE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return int
+ * @return bool
*/
- public function isTrendItemsEnabledInShoppingCart($storeId = null)
+ public function useBuiltInCron($storeId = null): bool
{
- return (int)$this->configInterface->getValue(
- self::IS_TREND_ITEMS_ENABLED_IN_SHOPPING_CART,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->isSetFlag(self::USE_BUILT_IN_CRON, ScopeInterface::SCOPE_STORE, $storeId);
}
+ // --- Indexing Manager --- //
+
/**
* @param $storeId
* @return bool
*/
- public function isAddToCartEnabledInFrequentlyBoughtTogether($storeId = null)
+ public function isIndexingEnabled($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::ENABLE_INDEXING, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isAddToCartEnabledInRelatedProducts($storeId = null)
+ public function isQuerySuggestionsIndexEnabled($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::ENABLE_QUERY_SUGGESTIONS_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return bool
*/
- public function isAddToCartEnabledInTrendsItem($storeId = null)
+ public function isPagesIndexEnabled($storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::ENABLE_PAGES_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
- * Determines whether add to cart is enabled in Looking Similar
- *
- * @param $storeId
* @return bool
*/
- public function isAddToCartEnabledInLookingSimilar($storeId = null)
+ public function isProductsIndexerEnabled(): bool
{
return $this->configInterface->isSetFlag(
- self::IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR,
- ScopeInterface::SCOPE_STORE,
- $storeId
+ self::ENABLE_INDEXER_PRODUCTS,
+ ScopeInterface::SCOPE_STORE
);
}
/**
- * @param $storeId
- * @return string
+ * @return bool
*/
- public function getFBTTitle($storeId = null)
+ public function isCategoriesIndexerEnabled(): bool
{
- return $this->configInterface->getValue(self::FREQUENTLY_BOUGHT_TOGETHER_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_CATEGORIES,
+ ScopeInterface::SCOPE_STORE
+ );
}
/**
- * @param $storeId
- * @return string
+ * @return bool
*/
- public function getRelatedProductsTitle($storeId = null)
+ public function isPagesIndexerEnabled(): bool
{
- return $this->configInterface->getValue(self::RELATED_PRODUCTS_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_PAGES,
+ ScopeInterface::SCOPE_STORE
+ );
}
/**
- * @param $storeId
- * @return string
+ * @return bool
*/
- public function getTrendingItemsTitle($storeId = null)
+ public function isSuggestionsIndexerEnabled(): bool
{
- return $this->configInterface->getValue(self::TRENDING_ITEMS_TITLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_SUGGESTIONS,
+ ScopeInterface::SCOPE_STORE
+ );
}
/**
- * @param $storeId
* @return bool
*/
- public function useAdaptiveImage($storeId = null)
+ public function isAdditionalSectionsIndexerEnabled(): bool
{
- return $this->configInterface->isSetFlag(self::USE_ADAPTIVE_IMAGE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_ADDITIONAL_SECTIONS,
+ ScopeInterface::SCOPE_STORE
+ );
}
/**
- * @param $storeId
* @return bool
*/
- public function isVisualMerchEnabled($storeId = null): bool
+ public function isDeleteProductsIndexerEnabled(): bool
{
- return $this->configInterface->isSetFlag(self::ENABLE_VISUAL_MERCHANDISING, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_DELETE_PRODUCTS,
+ ScopeInterface::SCOPE_STORE
+ );
}
/**
- * @param $storeId
- * @return string
+ * @return bool
*/
- public function getCategoryPageIdAttributeName($storeId = null): string
+ public function isQueueIndexerEnabled(): bool
{
- return (string) $this->configInterface->getValue(self::CATEGORY_PAGE_ID_ATTRIBUTE_NAME, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(
+ self::ENABLE_INDEXER_QUEUE,
+ ScopeInterface::SCOPE_STORE
+ );
}
+ // --- Click & Conversion Analytics --- //
+
/**
* @param $storeId
- * @return mixed
+ * @return bool
*/
- public function getInstantSelector($storeId = null)
+ public function isClickConversionAnalyticsEnabled($storeId = null): bool
{
- return $this->configInterface->getValue(self::INSTANT_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::CC_ANALYTICS_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return array
+ * @return mixed
*/
- public function getExcludedPages($storeId = null)
+ public function getClickConversionAnalyticsISSelector($storeId = null)
{
- $attrs = $this->unserialize($this->configInterface->getValue(
- self::EXCLUDED_PAGES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- if (is_array($attrs)) {
- return $attrs;
- }
- return [];
+ return $this->configInterface->getValue(self::CC_ANALYTICS_IS_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return mixed
*/
- public function getRenderTemplateDirectives($storeId = null)
+ public function getConversionAnalyticsMode($storeId = null)
{
return $this->configInterface->getValue(
- self::RENDER_TEMPLATE_DIRECTIVES,
+ self::CC_CONVERSION_ANALYTICS_MODE,
ScopeInterface::SCOPE_STORE,
$storeId
);
@@ -1014,182 +1124,64 @@ public function getRenderTemplateDirectives($storeId = null)
/**
* @param $storeId
- * @return bool
+ * @return mixed
*/
- public function isAutocompleteDebugEnabled($storeId = null)
- {
- return $this->configInterface->isSetFlag(self::AUTOCOMPLETE_MENU_DEBUG, ScopeInterface::SCOPE_STORE, $storeId);
- }
-
- public function getAutocompleteDebounceMilliseconds($storeId = null): int
+ public function getConversionAnalyticsAddToCartSelector($storeId = null)
{
- return (int) $this->configInterface->getValue(
- self::AUTOCOMPLETE_DEBOUNCE_MILLISEC,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->getValue(self::CC_ADD_TO_CART_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
}
- public function getAutocompleteMinimumCharacterLength($storeId = null): int
- {
- return (int) $this->configInterface->getValue(
- self::AUTOCOMPLETE_MINIMUM_CHAR_LENGTH,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
- }
+ // --- Google Analytics --- //
/**
- * @param $originalIndexName
* @param $storeId
- * @param $currentCustomerGroupId
- * @param $attrs
* @return array
- * @throws Magento\Framework\Exception\LocalizedException
- * @throws Magento\Framework\Exception\NoSuchEntityException
- * @deprecated This method has been deprecated and should no longer be used
- * @see \Algolia\AlgoliaSearch\Service\Product\SortingTransformer
*/
- public function getSortingIndices($originalIndexName, $storeId = null, $currentCustomerGroupId = null, $attrs = null)
+ public function getAnalyticsConfig($storeId = null)
{
- if (!$attrs){
- $attrs = $this->getSorting($storeId);
- }
-
- $currency = $this->getCurrencyCode($storeId);
- $attributesToAdd = [];
- foreach ($attrs as $key => $attr) {
- $indexName = false;
- $sortAttribute = false;
- if ($this->isCustomerGroupsEnabled($storeId) && $attr['attribute'] === 'price') {
- $websiteId = (int)$this->storeManager->getStore($storeId)->getWebsiteId();
- $groupCollection = $this->groupCollection;
- if (!is_null($currentCustomerGroupId)) {
- $groupCollection->addFilter('customer_group_id', $currentCustomerGroupId);
- }
- foreach ($groupCollection as $group) {
- $customerGroupId = (int)$group->getData('customer_group_id');
- $excludedWebsites = $this->groupExcludedWebsiteRepository->getCustomerGroupExcludedWebsites($customerGroupId);
- if (in_array($websiteId, $excludedWebsites)) {
- continue;
- }
- $groupIndexNameSuffix = 'group_' . $customerGroupId;
- $groupIndexName =
- $originalIndexName . '_' . $attr['attribute'] . '_' . $groupIndexNameSuffix . '_' . $attr['sort'];
- $groupSortAttribute = $attr['attribute'] . '.' . $currency . '.' . $groupIndexNameSuffix;
- $newAttr = [];
- $newAttr['name'] = $groupIndexName;
- $newAttr['attribute'] = $attr['attribute'];
- $newAttr['sort'] = $attr['sort'];
- $newAttr['sortLabel'] = $attr['sortLabel'];
- if (!array_key_exists('label', $newAttr) && array_key_exists('sortLabel', $newAttr)) {
- $newAttr['label'] = $newAttr['sortLabel'];
- }
- $newAttr['ranking'] = [
- $newAttr['sort'] . '(' . $groupSortAttribute . ')',
- 'typo',
- 'geo',
- 'words',
- 'filters',
- 'proximity',
- 'attribute',
- 'exact',
- 'custom',
- ];
- $attributesToAdd[$newAttr['sort']][] = $newAttr;
- }
- } elseif ($attr['attribute'] === 'price') {
- $indexName = $originalIndexName . '_' . $attr['attribute'] . '_' . 'default' . '_' . $attr['sort'];
- $sortAttribute = $attr['attribute'] . '.' . $currency . '.' . 'default';
- } else {
- $indexName = $originalIndexName . '_' . $attr['attribute'] . '_' . $attr['sort'];
- $sortAttribute = $attr['attribute'];
- }
- if ($indexName && $sortAttribute) {
- $attrs[$key]['name'] = $indexName;
- if (!array_key_exists('label', $attrs[$key]) && array_key_exists('sortLabel', $attrs[$key])) {
- $attrs[$key]['label'] = $attrs[$key]['sortLabel'];
- }
- $attrs[$key]['ranking'] = [
- $attr['sort'] . '(' . $sortAttribute . ')',
- 'typo',
- 'geo',
- 'words',
- 'filters',
- 'proximity',
- 'attribute',
- 'exact',
- 'custom',
- ];
- }
- }
- $attrsToReturn = [];
- if (count($attributesToAdd) > 0) {
- foreach ($attrs as $key => $attr) {
- if ($attr['attribute'] == 'price' && isset($attributesToAdd[$attr['sort']])) {
- $attrsToReturn = array_merge($attrsToReturn, $attributesToAdd[$attr['sort']]);
- } else {
- $attrsToReturn[] = $attr;
- }
- }
- }
- if (count($attrsToReturn) > 0) {
- return $attrsToReturn;
- }
- if (is_array($attrs)) {
- return $attrs;
- }
- return [];
- }
-
- /***
- * @param int|null $storeId
- * @return array>>
- */
- public function getSorting(?int $storeId = null): array
- {
- return $this->unserialize($this->getRawSortingValue($storeId));
+ return [
+ 'enabled' => $this->isAnalyticsEnabled(),
+ 'delay' => $this->configInterface->getValue(self::GA_DELAY, ScopeInterface::SCOPE_STORE, $storeId),
+ 'triggerOnUiInteraction' => $this->configInterface->getValue(
+ self::GA_TRIGGER_ON_UI_INTERACTION,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ),
+ 'pushInitialSearch' => $this->configInterface->getValue(
+ self::GA_PUSH_INITIAL_SEARCH,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ),
+ ];
}
/**
- * @param int|null $storeId
- * @return string
+ * @param $storeId
+ * @return bool
*/
- public function getRawSortingValue(?int $storeId = null): string
+ public function isAnalyticsEnabled($storeId = null): bool
{
- return (string) $this->configInterface->getValue(
- self::SORTING_INDICES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->configInterface->isSetFlag(self::GA_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
}
+ // --- Advanced --- //
+
/**
- * @param array $sorting
- * @param string|null $scope
- * @param int|null $scopeId
- * @return void
+ * @param $storeId
+ * @return mixed
*/
- public function setSorting(array $sorting, string $scope = Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, ?int $scopeId = null): void
+ public function getRemoveWordsIfNoResult($storeId = null)
{
- $this->configWriter->save(
- self::SORTING_INDICES,
- $this->serialize($sorting),
- $scope,
- $scopeId
- );
+ return $this->configInterface->getValue(self::REMOVE_IF_NO_RESULT, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return string
- * @throws Magento\Framework\Exception\NoSuchEntityException
+ * @return bool
*/
- public function getCurrencyCode($storeId = null)
+ public function isPartialUpdateEnabled($storeId = null): bool
{
- /** @var Magento\Store\Model\Store $store */
- $store = $this->storeManager->getStore($storeId);
- return $store->getCurrentCurrencyCode();
+ return $this->configInterface->isSetFlag(self::PARTIAL_UPDATES, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
@@ -1214,49 +1206,134 @@ public function setCustomerGroupsEnabled(bool $val, ?string $scope = null, ?int
/**
* @param $storeId
* @return bool
- * @deprecated Use Algolia\AlgoliaSearch\Service\AlgoliaCredentialsManager instead
*/
- public function credentialsAreConfigured($storeId = null)
+ public function shouldRemovePubDirectory($storeId = null): bool
{
- return $this->getApplicationID($storeId) &&
- $this->getAPIKey($storeId) &&
- $this->getSearchOnlyAPIKey($storeId);
+ return $this->configInterface->isSetFlag(self::REMOVE_PUB_DIR_IN_URL, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return mixed'
+ * @return bool
*/
- public function getApplicationID($storeId = null)
+ public function isRemoveBranding($storeId = null): bool
{
- return $this->configInterface->getValue(self::APPLICATION_ID, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->isSetFlag(self::REMOVE_BRANDING, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
* @return mixed
*/
- public function getAPIKey($storeId = null)
+ public function indexProductOnCategoryProductsUpdate($storeId = null)
{
- return $this->configInterface->getValue(self::API_KEY, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::IDX_PRODUCT_ON_CAT_PRODUCTS_UPD,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+
+ /**
+ * @param $storeId
+ * @return bool
+ * @deprecated This feature is deprecated and will be replaced in an upcoming version
+ */
+ public function preventBackendRendering($storeId = null): bool
+ {
+ $preventBackendRendering = $this->configInterface->isSetFlag(
+ self::PREVENT_BACKEND_RENDERING,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ if ($preventBackendRendering === false) {
+ return false;
+ }
+ if (!isset($_SERVER['HTTP_USER_AGENT'])) {
+ return false;
+ }
+ $userAgent = mb_strtolower((string) filter_input(INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_SPECIAL_CHARS), 'utf-8');
+
+ $allowedUserAgents = $this->configInterface->getValue(
+ self::BACKEND_RENDERING_ALLOWED_USER_AGENTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ $allowedUserAgents = trim((string) $allowedUserAgents);
+ if ($allowedUserAgents === '') {
+ return true;
+ }
+ $allowedUserAgents = preg_split('/\n|\r\n?/', $allowedUserAgents);
+ $allowedUserAgents = array_filter($allowedUserAgents);
+ foreach ($allowedUserAgents as $allowedUserAgent) {
+ $allowedUserAgent = mb_strtolower($allowedUserAgent, 'utf-8');
+ if (mb_strpos($userAgent, $allowedUserAgent) !== false) {
+ return false;
+ }
+ }
+ return true;
}
/**
* @param $storeId
* @return mixed
*/
- public function getSearchOnlyAPIKey($storeId = null)
+ public function getBackendRenderingDisplayMode($storeId = null)
{
- return $this->configInterface->getValue(self::SEARCH_ONLY_API_KEY, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::PREVENT_BACKEND_RENDERING_DISPLAY_MODE,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
- * @param int|null $storeId
+ * @param $storeId
+ * @return array
+ */
+ public function getNonCastableAttributes($storeId = null)
+ {
+ $nonCastableAttributes = [];
+ $config = $this->serializer->unserialize($this->configInterface->getValue(
+ self::NON_CASTABLE_ATTRIBUTES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ if (is_array($config)) {
+ foreach ($config as $attributeData) {
+ if (isset($attributeData['attribute'])) {
+ $nonCastableAttributes[] = $attributeData['attribute'];
+ }
+ }
+ }
+ return $nonCastableAttributes;
+ }
+
+ /**
+ * @param $storeId
+ * @return int
+ */
+ public function getMaxRecordSizeLimit($storeId = null)
+ {
+ return (int) $this->configInterface->getValue(
+ self::MAX_RECORD_SIZE_LIMIT,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ /**
+ * @param $storeId
* @return string
*/
- public function getIndexPrefix(int $storeId = null): string
+ public function getAnalyticsRegion($storeId = null)
{
- return (string) $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->configInterface->getValue(
+ self::ANALYTICS_REGION,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
}
/**
@@ -1286,6 +1363,15 @@ public function getWriteTimeout($storeId = null)
return $this->configInterface->getValue(self::WRITE_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
}
+ public function shouldForwardPrimaryIndexSettingsToReplicas(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::FORWARD_TO_REPLICAS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
public function isAutoPriceIndexingEnabled(?int $storeId = null): bool
{
return $this->configInterface->isSetFlag(
@@ -1295,142 +1381,114 @@ public function isAutoPriceIndexingEnabled(?int $storeId = null): bool
);
}
+ public function isProfilerEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::PROFILER_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ // Indexing Queue advanced settings
/**
* @param $storeId
- * @return array|bool|float|int|mixed|string
+ * @return int
*/
- public function getFacets($storeId = null)
+ public function getNumberOfElementByPage($storeId = null): int
{
- $attrs = $this->unserialize($this->configInterface->getValue(
- self::FACETS,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- if ($attrs) {
- foreach ($attrs as &$attr) {
- if ($attr['type'] === 'other') {
- $attr['type'] = $attr['other_type'];
- }
- }
- if (is_array($attrs)) {
- return array_values($attrs);
- }
- }
- return [];
+ return (int) $this->configInterface->getValue(self::NUMBER_OF_ELEMENT_BY_PAGE, ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $storeId
- * @return array
+ * @return int
*/
- public function getCategoryCustomRanking($storeId = null)
+ public function getArchiveLogClearLimit($storeId = null)
{
- $attrs = $this->unserialize($this->configInterface->getValue(
- self::CATEGORY_CUSTOM_RANKING,
+ return (int)$this->configInterface->getValue(
+ self::ARCHIVE_LOG_CLEAR_LIMIT,
ScopeInterface::SCOPE_STORE,
$storeId
- ));
- if (is_array($attrs)) {
- return $attrs;
- }
- return [];
+ );
}
/**
* @param $storeId
- * @return array
+ * @return bool
*/
- public function getProductCustomRanking($storeId = null)
+ public function isEnhancedQueueArchiveEnabled($storeId = null): bool
{
- $attrs = $this->unserialize($this->getRawProductCustomRanking($storeId));
- if (is_array($attrs)) {
- return $attrs;
- }
- return [];
+ return $this->configInterface->isSetFlag(self::ENHANCED_QUEUE_ARCHIVE, ScopeInterface::SCOPE_STORE, $storeId);
}
+ // --- Extra index settings --- //
+
/**
+ * @param $section
* @param $storeId
- * @return mixed
+ * @return string
*/
- public function getRawProductCustomRanking($storeId = null)
+ public function getExtraSettings($section, $storeId = null): string
{
- return $this->configInterface->getValue(
- self::PRODUCT_CUSTOM_RANKING,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ $constant = 'EXTRA_SETTINGS_' . mb_strtoupper((string) $section);
+ $value = $this->configInterface->getValue(constant('self::' . $constant), ScopeInterface::SCOPE_STORE, $storeId);
+ return trim((string)$value);
}
+ // --- Magento Core --- //
+
/**
- * @param $section
- * @param $storeId
* @return string
*/
- public function getExtraSettings($section, $storeId = null)
+ public function getMagentoVersion()
{
- $constant = 'EXTRA_SETTINGS_' . mb_strtoupper($section);
- $value = $this->configInterface->getValue(constant('self::' . $constant), ScopeInterface::SCOPE_STORE, $storeId);
- return trim((string)$value);
+ return $this->productMetadata->getVersion();
}
/**
- * @param $storeId
- * @return bool
- * @deprecated This feature is deprecated and will be replaced in an upcoming version
+ * @return string
*/
- public function preventBackendRendering($storeId = null)
+ public function getMagentoEdition()
{
- $preventBackendRendering = $this->configInterface->isSetFlag(
- self::PREVENT_BACKEND_RENDERING,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
- if ($preventBackendRendering === false) {
- return false;
- }
- if (!isset($_SERVER['HTTP_USER_AGENT'])) {
- return false;
- }
- $userAgent = mb_strtolower($_SERVER['HTTP_USER_AGENT'], 'utf-8');
- $allowedUserAgents = $this->configInterface->getValue(
- self::BACKEND_RENDERING_ALLOWED_USER_AGENTS,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
- $allowedUserAgents = trim($allowedUserAgents);
- if ($allowedUserAgents === '') {
- return true;
- }
- $allowedUserAgents = preg_split('/\n|\r\n?/', $allowedUserAgents);
- $allowedUserAgents = array_filter($allowedUserAgents);
- foreach ($allowedUserAgents as $allowedUserAgent) {
- $allowedUserAgent = mb_strtolower($allowedUserAgent, 'utf-8');
- if (mb_strpos($userAgent, $allowedUserAgent) !== false) {
- return false;
- }
- }
- return true;
+ return $this->productMetadata->getEdition();
}
/**
- * @param $storeId
- * @return mixed
+ * @return false|string
*/
- public function getBackendRenderingDisplayMode($storeId = null)
+ public function getExtensionVersion()
{
- return $this->configInterface->getValue(
- self::PREVENT_BACKEND_RENDERING_DISPLAY_MODE,
- ScopeInterface::SCOPE_STORE,
- $storeId
+ return $this->moduleResource->getDbVersion('Algolia_AlgoliaSearch');
+ }
+
+ /**
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
+ */
+ public function getCurrencyCode(?int $storeId = null): string
+ {
+ /** @var \Magento\Store\Model\Store $store */
+ $store = $this->storeManager->getStore($storeId);
+ return $store->getCurrentCurrencyCode();
+ }
+
+ /**
+ * Obtain the store scoped currency configuration or fall back to all allowed currencies
+ * @return array
+ */
+ public function getAllowedCurrencies(?int $storeId = null): array
+ {
+ $configured = explode(
+ ',',
+ $this->configInterface->getValue(
+ DirCurrency::XML_PATH_CURRENCY_ALLOW,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ) ?? ''
);
+ return $configured ?: $this->dirCurrency->getConfigAllowCurrencies();
}
/**
- * @return int
- * @throws Magento\Framework\Exception\NoSuchEntityException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
*/
- public function getStoreId()
+ public function getStoreId(): int
{
return $this->storeManager->getStore()->getId();
}
@@ -1451,11 +1509,11 @@ public function getStoreLocale($storeId)
/**
* @param $storeId
* @return string|null
- * @throws Magento\Framework\Exception\NoSuchEntityException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getCurrency($storeId = null)
{
- /** @var Magento\Store\Model\Store $store */
+ /** @var \Magento\Store\Model\Store $store */
$store = $this->storeManager->getStore($storeId);
return $this->currency->getCurrency($store->getCurrentCurrencyCode())->getSymbol();
}
@@ -1464,446 +1522,592 @@ public function getCurrency($storeId = null)
* @param $storeId
* @return bool
*/
- public function showSuggestionsOnNoResultsPage($storeId = null)
+ public function getShowOutOfStock($storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::SHOW_OUT_OF_STOCK, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ /**
+ * @param $storeId
+ * @return bool
+ */
+ public function useSecureUrlsInFrontend($storeId = null): bool
{
return $this->configInterface->isSetFlag(
- self::SHOW_SUGGESTIONS_NO_RESULTS,
+ self::USE_SECURE_IN_FRONTEND,
ScopeInterface::SCOPE_STORE,
$storeId
);
}
/**
- * @param $groupId
- * @return array
+ * @return bool
*/
- public function getAttributesToRetrieve($groupId)
+ public function isCookieRestrictionModeEnabled(): bool
{
- if (false === $this->isCustomerGroupsEnabled()) {
- return [];
- }
- $attributes = [];
- foreach ($this->getProductAdditionalAttributes() as $attribute) {
- if ($attribute['attribute'] !== 'price' && $attribute['retrievable'] === '1') {
- $attributes[] = $attribute['attribute'];
- }
- }
- foreach ($this->getCategoryAdditionalAttributes() as $attribute) {
- if ($attribute['retrievable'] === '1') {
- $attributes[] = $attribute['attribute'];
- }
- }
- $attributes = array_merge($attributes, [
- AlgoliaConnector::ALGOLIA_API_OBJECT_ID,
- 'name',
- 'url',
- 'visibility_search',
- 'visibility_catalog',
- 'categories',
- 'categories_without_path',
- 'thumbnail_url',
- 'image_url',
- 'images_data',
- 'in_stock',
- 'type_id',
- 'value',
- 'query', # suggestions
- 'path', # categories
- 'default_bundle_options',
- ]);
- $currencies = $this->dirCurrency->getConfigAllowCurrencies();
- foreach ($currencies as $currency) {
- $attributes[] = 'price.' . $currency . '.default';
- $attributes[] = 'price.' . $currency . '.default_tier';
- $attributes[] = 'price.' . $currency . '.default_max';
- $attributes[] = 'price.' . $currency . '.default_formated';
- $attributes[] = 'price.' . $currency . '.default_original_formated';
- $attributes[] = 'price.' . $currency . '.default_tier_formated';
- $attributes[] = 'price.' . $currency . '.group_' . $groupId;
- $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_tier';
- $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_max';
- $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_formated';
- $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_tier_formated';
- $attributes[] = 'price.' . $currency . '.group_' . $groupId . '_original_formated';
- $attributes[] = 'price.' . $currency . '.special_from_date';
- $attributes[] = 'price.' . $currency . '.special_to_date';
- }
- $transport = new DataObject($attributes);
- $this->eventManager->dispatch('algolia_get_retrievable_attributes', ['attributes' => $transport]);
- $attributes = $transport->getData();
- $attributes = array_unique($attributes);
- $attributes = array_values($attributes);
- return ['attributesToRetrieve' => $attributes];
+ return (bool) $this->cookieHelper->isCookieRestrictionModeEnabled();
}
/**
* @param $storeId
- * @return array
+ * @return mixed
*/
- public function getProductAdditionalAttributes($storeId = null)
+ public function getCookieLifetime($storeId = null)
{
- $attributes = $this->unserialize($this->configInterface->getValue(
- self::PRODUCT_ATTRIBUTES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
+ return $this->configInterface->getValue(self::COOKIE_LIFETIME, ScopeInterface::SCOPE_STORE, $storeId);
+ }
- $facets = $this->unserialize($this->configInterface->getValue(
- self::FACETS,
+ /**
+ * @param $storeId
+ * @return mixed
+ */
+ public function getCacheTime($storeId = null)
+ {
+ return $this->configInterface->getValue(
+ self::MAGENTO_DEFAULT_CACHE_TIME,
ScopeInterface::SCOPE_STORE,
$storeId
- ));
- $attributes = $this->addIndexableAttributes($attributes, $facets, '0');
+ );
+ }
- $sorts = $this->unserialize($this->configInterface->getValue(
- self::SORTING_INDICES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- $attributes = $this->addIndexableAttributes($attributes, $sorts, '0');
+ /***************************************
+ * DEPRECATED CONSTANTS & METHODS *
+ **************************************/
- $customRankings = $this->unserialize($this->configInterface->getValue(
- self::PRODUCT_CUSTOM_RANKING,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- $customRankings = $customRankings ?: [];
- $customRankings = array_filter($customRankings, function ($customRanking) {
- return $customRanking['attribute'] !== 'custom_attribute';
- });
- $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0');
- if (is_array($attributes)) {
- return $attributes;
- }
- return [];
+ /*** CONSTANTS ***/
+
+ // --- Autocomplete --- //
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::IS_ENABLED
+ */
+ public const IS_POPUP_ENABLED = AutocompleteHelper::IS_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::DOM_SELECTOR
+ */
+ public const AUTOCOMPLETE_SELECTOR = AutocompleteHelper::DOM_SELECTOR;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::ADDITIONAL_SECTIONS
+ */
+ public const AUTOCOMPLETE_SECTIONS = AutocompleteHelper::ADDITIONAL_SECTIONS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::NB_OF_PRODUCTS_SUGGESTIONS
+ */
+ public const NB_OF_PRODUCTS_SUGGESTIONS = AutocompleteHelper::NB_OF_PRODUCTS_SUGGESTIONS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::NB_OF_CATEGORIES_SUGGESTIONS
+ */
+ public const NB_OF_CATEGORIES_SUGGESTIONS = AutocompleteHelper::NB_OF_CATEGORIES_SUGGESTIONS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::NB_OF_QUERIES_SUGGESTIONS
+ */
+ public const NB_OF_QUERIES_SUGGESTIONS = AutocompleteHelper::NB_OF_QUERIES_SUGGESTIONS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::MIN_QUERY_POPULARITY
+ */
+ public const MIN_POPULARITY = AutocompleteHelper::MIN_QUERY_POPULARITY;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::MIN_QUERY_NUMBER_OF_RESULTS
+ */
+ public const MIN_NUMBER_OF_RESULTS = AutocompleteHelper::MIN_QUERY_NUMBER_OF_RESULTS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::EXCLUDED_PAGES
+ */
+ public const EXCLUDED_PAGES = AutocompleteHelper::EXCLUDED_PAGES;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::RENDER_TEMPLATE_DIRECTIVES
+ */
+ public const RENDER_TEMPLATE_DIRECTIVES = AutocompleteHelper::RENDER_TEMPLATE_DIRECTIVES;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::IS_DEBUG_ENABLED
+ */
+ public const AUTOCOMPLETE_MENU_DEBUG = AutocompleteHelper::IS_DEBUG_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::DEBOUNCE_MILLISEC
+ */
+ public const AUTOCOMPLETE_DEBOUNCE_MILLISEC = AutocompleteHelper::DEBOUNCE_MILLISEC;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::MINIMUM_CHAR_LENGTH
+ */
+ public const AUTOCOMPLETE_MINIMUM_CHAR_LENGTH = AutocompleteHelper::MINIMUM_CHAR_LENGTH;
+
+ // --- InstantSearch --- //
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::IS_ENABLED
+ */
+ public const IS_INSTANT_ENABLED = InstantSearchHelper::IS_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::DOM_SELECTOR
+ */
+ public const INSTANT_SELECTOR = InstantSearchHelper::DOM_SELECTOR;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::NUMBER_OF_PRODUCT_RESULTS
+ */
+ public const NUMBER_OF_PRODUCT_RESULTS = InstantSearchHelper::NUMBER_OF_PRODUCT_RESULTS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::REPLACE_CATEGORIES
+ */
+ public const REPLACE_CATEGORIES = InstantSearchHelper::REPLACE_CATEGORIES;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::FACETS
+ */
+ public const FACETS = InstantSearchHelper::FACETS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::MAX_VALUES_PER_FACET
+ */
+ public const MAX_VALUES_PER_FACET = InstantSearchHelper::MAX_VALUES_PER_FACET;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::IS_DYNAMIC_FACETS_ENABLED
+ */
+ public const ENABLE_DYNAMIC_FACETS = InstantSearchHelper::IS_DYNAMIC_FACETS_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::SORTING_INDICES
+ */
+ public const SORTING_INDICES = InstantSearchHelper::SORTING_INDICES;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::SHOW_SUGGESTIONS_NO_RESULTS
+ */
+ public const SHOW_SUGGESTIONS_NO_RESULTS = InstantSearchHelper::SHOW_SUGGESTIONS_NO_RESULTS;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::IS_SEARCHBOX_ENABLED
+ */
+ public const SEARCHBOX_ENABLE = InstantSearchHelper::IS_SEARCHBOX_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::IS_ADD_TO_CART_ENABLED
+ */
+ public const XML_ADD_TO_CART_ENABLE = InstantSearchHelper::IS_ADD_TO_CART_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::IS_INFINITE_SCROLL_ENABLED
+ */
+ public const INFINITE_SCROLL_ENABLE = InstantSearchHelper::IS_INFINITE_SCROLL_ENABLED;
+
+ /**
+ * @deprecated This constant has been moved to a domain specific config helper and will be removed in a future release
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::HIDE_PAGINATION
+ */
+ public const HIDE_PAGINATION = InstantSearchHelper::HIDE_PAGINATION;
+
+ /**
+ * @deprecated This constant is retained purely for data patches to migrate from older versions
+ */
+ public const LEGACY_USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
+
+ // --- Indexing Manager --- //
+
+ /**
+ * @deprecated This constant has been renamed to be more meaningful and to avoid confusion with "backend rendering" statements
+ * @see \Algolia\AlgoliaSearch\Helper\ConfigHelper::ENABLE_INDEXING
+ */
+ public const ENABLE_BACKEND = self::ENABLE_INDEXING;
+
+ // --- Advanced --- //
+ /**
+ * @deprecated This configuration is no longer being used and will be removed in a future release
+ */
+ public const MAKE_SEO_REQUEST = 'algoliasearch_advanced/advanced/make_seo_request';
+
+ /*** METHODS ***/
+
+ // --- Autocomplete --- //
+
+ /**
+ * @param $storeId
+ * @return bool
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::isEnabled
+ */
+ public function isAutoCompleteEnabled($storeId = null)
+ {
+ return $this->autocompleteConfig->isEnabled($storeId);
+ }
+
+ /**
+ * @param $storeId
+ * @return bool
+ * @internal This is an internal function only and should not be used by customizations
+ */
+ public function isDefaultSelector($storeId = null)
+ {
+ return '.algolia-search-input' === $this->getAutocompleteSelector($storeId);
}
/**
- * @param $attributes
- * @param $addedAttributes
- * @param $searchable
- * @param $retrievable
- * @param $indexNoValue
+ * @param $storeId
* @return mixed
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getDomSelector()
*/
- protected function addIndexableAttributes(
- $attributes,
- $addedAttributes,
- $searchable = '1',
- $retrievable = '1',
- $indexNoValue = '1'
- ) {
- foreach ((array)$addedAttributes as $addedAttribute) {
- foreach ((array)$attributes as $attribute) {
- if ($addedAttribute['attribute'] === $attribute['attribute']) {
- continue 2;
- }
- }
- $attributes[] = [
- 'attribute' => $addedAttribute['attribute'],
- 'searchable' => $searchable,
- 'retrievable' => $retrievable,
- 'index_no_value' => $indexNoValue,
- ];
- }
- return $attributes;
+ public function getAutocompleteSelector($storeId = null)
+ {
+ return $this->autocompleteConfig->getDomSelector($storeId);
}
/**
* @param $storeId
* @return array
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getAdditionalSections()
*/
- public function getCategoryAdditionalAttributes($storeId = null)
+ public function getAutocompleteSections($storeId = null)
{
- $attributes = $this->unserialize($this->configInterface->getValue(
- self::CATEGORY_ATTRIBUTES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- $customRankings = $this->unserialize($this->configInterface->getValue(
- self::CATEGORY_CUSTOM_RANKING,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- $customRankings = $customRankings ?: [];
- $customRankings = array_filter($customRankings, function ($customRanking) {
- return $customRanking['attribute'] !== 'custom_attribute';
- });
- $attributes = $this->addIndexableAttributes($attributes, $customRankings, '0', '0');
- if (is_array($attributes)) {
- return $attributes;
- }
- return [];
+ return $this->autocompleteConfig->getAdditionalSections($storeId);
}
/**
* @param $storeId
- * @return string
+ * @return int
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getNumberOfProductsSuggestions()
*/
- public function getCategorySeparator($storeId = null): string
+ public function getNumberOfProductsSuggestions($storeId = null)
{
- return (string) $this->configInterface->getValue(self::CATEGORY_SEPARATOR, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->autocompleteConfig->getNumberOfProductsSuggestions($storeId);
}
/**
- * @param $groupId
- * @return array
+ * @param $storeId
+ * @return int
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getNumberOfCategoriesSuggestions()
*/
- public function getAttributesToFilter($groupId)
+ public function getNumberOfCategoriesSuggestions($storeId = null)
{
- $transport = new DataObject();
- $this->eventManager->dispatch(
- 'algolia_get_attributes_to_filter',
- ['filter_object' => $transport, 'customer_group_id' => $groupId]
- );
- $attributes = $transport->getData();
- $attributes = array_unique($attributes);
- $attributes = array_values($attributes);
- return count($attributes) ? ['filters' => implode(' AND ', $attributes)] : [];
+ return $this->autocompleteConfig->getNumberOfCategoriesSuggestions($storeId);
}
/**
* @param $storeId
- * @return bool
+ * @return int
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getNumberOfQueriesSuggestions()
*/
- public function isClickConversionAnalyticsEnabled($storeId = null)
+ public function getNumberOfQueriesSuggestions($storeId = null)
{
- return $this->configInterface->isSetFlag(self::CC_ANALYTICS_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->autocompleteConfig->getNumberOfQueriesSuggestions($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return int
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getMinQueryPopularity()
*/
- public function getClickConversionAnalyticsISSelector($storeId = null)
+ public function getMinPopularity($storeId = null)
{
- return $this->configInterface->getValue(self::CC_ANALYTICS_IS_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->autocompleteConfig->getMinQueryPopularity($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return int
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getMinQueryNumberOfResults()
*/
- public function getConversionAnalyticsMode($storeId = null)
+ public function getMinNumberOfResults($storeId = null)
{
- return $this->configInterface->getValue(
- self::CC_CONVERSION_ANALYTICS_MODE,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->autocompleteConfig->getMinQueryNumberOfResults($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return array
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getExcludedPages()
*/
- public function getConversionAnalyticsAddToCartSelector($storeId = null)
+ public function getExcludedPages($storeId = null)
{
- return $this->configInterface->getValue(self::CC_ADD_TO_CART_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->autocompleteConfig->getExcludedPages($storeId);
}
/**
* @param $storeId
* @return mixed
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::shouldRenderTemplateDirectives()
*/
- public function getDefaultConsentCookieName($storeId = null)
+ public function getRenderTemplateDirectives($storeId = null)
{
- return $this->configInterface->getValue(
- self::COOKIE_DEFAULT_CONSENT_COOKIE_NAME,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->autocompleteConfig->shouldRenderTemplateDirectives($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return bool
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::isDebugEnabled()
*/
- public function getAllowCookieButtonSelector($storeId = null)
+ public function isAutocompleteDebugEnabled($storeId = null)
{
- return $this->configInterface->getValue(
- self::ALLOW_COOKIE_BUTTON_SELECTOR,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->autocompleteConfig->isDebugEnabled($storeId);
}
/**
* @param $storeId
* @return mixed
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::isKeyboardNavigationEnabled()
*/
- public function getAlgoliaCookieDuration($storeId = null)
+ public function isAutocompleteNavigatorEnabled($storeId = null)
{
- return $this->configInterface->getValue(
- self::ALGOLIA_COOKIE_DURATION,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->autocompleteConfig->isKeyboardNavigationEnabled($storeId);
}
/**
- * @param $storeId
- * @return array
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getDebounceMilliseconds()
*/
- public function getAnalyticsConfig($storeId = null)
+ public function getAutocompleteDebounceMilliseconds($storeId = null): int
{
- return [
- 'enabled' => $this->isAnalyticsEnabled(),
- 'delay' => $this->configInterface->getValue(self::GA_DELAY, ScopeInterface::SCOPE_STORE, $storeId),
- 'triggerOnUiInteraction' => $this->configInterface->getValue(
- self::GA_TRIGGER_ON_UI_INTERACTION,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ),
- 'pushInitialSearch' => $this->configInterface->getValue(
- self::GA_PUSH_INITIAL_SEARCH,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ),
- ];
+ return $this->autocompleteConfig->getDebounceMilliseconds($storeId);
+ }
+
+ /**
+ * @deprecated This method has been moved to the Autocomplete config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper::getMinimumCharacterLength()
+ */
+ public function getAutocompleteMinimumCharacterLength(?int $storeId = null): int
+ {
+ return $this->autocompleteConfig->getMinimumCharacterLength($storeId);
}
+ // --- InstantSearch --- //
+
/**
* @param $storeId
* @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::isEnabled()
+ * /
*/
- public function isAnalyticsEnabled($storeId = null)
+ public function isInstantEnabled($storeId = null)
{
- return $this->configInterface->isSetFlag(self::GA_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->instantSearchConfig->isEnabled($storeId);
}
/**
* @param $storeId
- * @return array
+ * @return mixed
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getDomSelector()
*/
- public function getNonCastableAttributes($storeId = null)
+ public function getInstantSelector($storeId = null)
{
- $nonCastableAttributes = [];
- $config = $this->unserialize($this->configInterface->getValue(
- self::NON_CASTABLE_ATTRIBUTES,
- ScopeInterface::SCOPE_STORE,
- $storeId
- ));
- if (is_array($config)) {
- foreach ($config as $attributeData) {
- if (isset($attributeData['attribute'])) {
- $nonCastableAttributes[] = $attributeData['attribute'];
- }
- }
- }
- return $nonCastableAttributes;
+ return $this->instantSearchConfig->getDomSelector($storeId);
}
/**
* @param $storeId
* @return int
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getNumberOfProductResults()
*/
- public function getMaxRecordSizeLimit($storeId = null)
+ public function getNumberOfProductResults($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::MAX_RECORD_SIZE_LIMIT,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->instantSearchConfig->getNumberOfProductResults($storeId);
}
/**
* @param $storeId
- * @return string
+ * @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::shouldReplaceCategories()
*/
- public function getAnalyticsRegion($storeId = null)
+ public function replaceCategories($storeId = null)
{
- return $this->configInterface->getValue(
- self::ANALYTICS_REGION,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->instantSearchConfig->shouldReplaceCategories($storeId);
}
/**
* @param $storeId
- * @return bool
+ * @return array|bool|float|int|mixed|string
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getFacets()
*/
- public function isQuerySuggestionsIndexEnabled($storeId = null)
+ public function getFacets($storeId = null)
{
- return $this->configInterface->isSetFlag(self::ENABLE_QUERY_SUGGESTIONS_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->instantSearchConfig->getFacets($storeId);
}
/**
* @param $storeId
+ * @return int
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getMaxValuesPerFacet()
+ */
+ public function getMaxValuesPerFacet($storeId = null)
+ {
+ return $this->instantSearchConfig->getMaxValuesPerFacet($storeId);
+ }
+
+ /**
+ * @param int|null $storeId
* @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::isDynamicFacetsEnabled()
*/
- public function isPagesIndexEnabled($storeId = null)
+ public function isDynamicFacetsEnabled(?int $storeId = null): bool
{
- return $this->configInterface->isSetFlag(self::ENABLE_PAGES_INDEX, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->instantSearchConfig->isDynamicFacetsEnabled($storeId);
+ }
+
+ /***
+ * @param int|null $storeId
+ * @return array>>
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getSorting()
+ */
+ public function getSorting(?int $storeId = null): array
+ {
+ return $this->instantSearchConfig->getSorting($storeId);
+ }
+
+ /**
+ * @param int|null $storeId
+ * @return string
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::getRawSortingValue()
+ */
+ public function getRawSortingValue(?int $storeId = null): string
+ {
+ return $this->instantSearchConfig->getRawSortingValue($storeId);
+ }
+
+ /**
+ * @param array $sorting
+ * @param string|null $scope
+ * @param int|null $scopeId
+ * @return void
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::setSorting()
+ */
+ public function setSorting(array $sorting, string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, ?int $scopeId = null): void
+ {
+ $this->instantSearchConfig->setSorting($sorting, $scope, $scopeId);
}
/**
* @param $storeId
- * @return int
+ * @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::isSearchBoxEnabled()
*/
- public function getArchiveLogClearLimit($storeId = null)
+ public function isInstantSearchBoxEnabled($storeId = null)
{
- return (int)$this->configInterface->getValue(
- self::ARCHIVE_LOG_CLEAR_LIMIT,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->instantSearchConfig->isSearchBoxEnabled($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::shouldShowSuggestionsOnNoResultsPage()
*/
- public function getCacheTime($storeId = null)
+ public function showSuggestionsOnNoResultsPage($storeId = null)
{
- return $this->configInterface->getValue(
- self::MAGENTO_DEFAULT_CACHE_TIME,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->instantSearchConfig->shouldShowSuggestionsOnNoResultsPage($storeId);
}
/**
- * @param int|null $storeId
+ * @param $storeId
* @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::isAddToCartEnabled()
*/
- public function useVirtualReplica(?int $storeId = null): bool
+ public function isAddToCartEnable($storeId = null)
{
- return (bool) count(array_filter(
- $this->getSorting($storeId),
- function ($sort) {
- return $sort[ReplicaManagerInterface::SORT_KEY_VIRTUAL_REPLICA];
- }
- ));
+ return $this->instantSearchConfig->isAddToCartEnabled($storeId);
}
/**
* @param $storeId
- * @return mixed
+ * @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::isInfiniteScrollEnabled()
*/
- public function isAutocompleteNavigatorEnabled($storeId = null)
+ public function isInfiniteScrollEnabled($storeId = null)
{
- return $this->configInterface->isSetFlag(self::AUTOCOMPLETE_KEYBORAD_NAVIAGATION,
- ScopeInterface::SCOPE_STORE,
- $storeId
- );
+ return $this->instantSearchConfig->isInfiniteScrollEnabled($storeId);
}
/**
+ * @param $storeId
* @return bool
+ * @deprecated This method has been moved to the InstantSearch config helper and will be removed in a future version
+ * @see \Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper::shouldHidePagination()
*/
- public function isCookieRestrictionModeEnabled()
+ public function hidePaginationInInstantSearchPage($storeId = null)
{
- return (bool)$this->cookieHelper->isCookieRestrictionModeEnabled();
+ return $this->instantSearchConfig->shouldHidePagination($storeId);
}
+ // --- Indexing Manager --- //
+
/**
* @param $storeId
- * @return mixed
+ * @return bool
+ * @deprecated This method has been renamed to be more meaningful and to avoid confusion with "backend rendering" statements
+ * @see \Algolia\AlgoliaSearch\Helper\ConfigHelper::isIndexingEnabled()
*/
- public function getCookieLifetime($storeId = null)
+ public function isEnabledBackend($storeId = null)
{
- return $this->configInterface->getValue(self::COOKIE_LIFETIME, ScopeInterface::SCOPE_STORE, $storeId);
+ return $this->isIndexingEnabled($storeId);
+ }
+
+ // --- Advanced --- //
+ /**
+ * @deprecated This configuration is no longer being used and will be removed in a future release
+ */
+ public function makeSeoRequest($storeId = null)
+ {
+ return $this->configInterface->isSetFlag(self::MAKE_SEO_REQUEST, ScopeInterface::SCOPE_STORE, $storeId);
}
}
diff --git a/Helper/Configuration/AutocompleteHelper.php b/Helper/Configuration/AutocompleteHelper.php
new file mode 100644
index 000000000..0b014440b
--- /dev/null
+++ b/Helper/Configuration/AutocompleteHelper.php
@@ -0,0 +1,190 @@
+configInterface->isSetFlag(self::IS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getDomSelector(?int $storeId = null): string
+ {
+ return $this->configInterface->getValue(self::DOM_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getAdditionalSections(?int $storeId = null): array
+ {
+ $attrs = $this->serializer->unserialize(
+ $this->configInterface->getValue(
+ self::ADDITIONAL_SECTIONS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ )
+ );
+
+ if (is_array($attrs)) {
+ return array_values($attrs);
+ }
+
+ return [];
+ }
+
+ public function getNumberOfProductsSuggestions(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::NB_OF_PRODUCTS_SUGGESTIONS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function getNumberOfCategoriesSuggestions(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::NB_OF_CATEGORIES_SUGGESTIONS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function getNumberOfQueriesSuggestions(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::NB_OF_QUERIES_SUGGESTIONS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ /** Throttles query suggestions that are indexed from Magento to Algolia */
+ public function getMinQueryPopularity(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::MIN_QUERY_POPULARITY,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ /** Throttles query suggestions that are indexed from Magento to Algolia */
+ public function getMinQueryNumberOfResults(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::MIN_QUERY_NUMBER_OF_RESULTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ /**
+ * Retrieve CMS pages to be excluded from the Autocomplete search
+ * Also impacts what pages are indexed
+ */
+ public function getExcludedPages(?int $storeId = null): array
+ {
+ $attrs = $this->serializer->unserialize(
+ $this->configInterface->getValue(
+ self::EXCLUDED_PAGES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ )
+ );
+
+ if (is_array($attrs)) {
+ return $attrs;
+ }
+
+ return [];
+ }
+
+ /**
+ * This setting impacts what content is indexed for CMS page search
+ */
+ public function shouldRenderTemplateDirectives(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::RENDER_TEMPLATE_DIRECTIVES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isDebugEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::IS_DEBUG_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function isKeyboardNavigationEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::IS_KEYBOARD_NAV_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getDebounceMilliseconds($storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(self::DEBOUNCE_MILLISEC, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getMinimumCharacterLength(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::MINIMUM_CHAR_LENGTH,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isRedirectEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::IS_REDIRECT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getRedirectMode(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::REDIRECT_MODE,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isRedirectInNewWindowEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::OPEN_REDIRECT_IN_NEW_WINDOW,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+}
diff --git a/Helper/Configuration/InstantSearchHelper.php b/Helper/Configuration/InstantSearchHelper.php
new file mode 100644
index 000000000..3191dd50b
--- /dev/null
+++ b/Helper/Configuration/InstantSearchHelper.php
@@ -0,0 +1,184 @@
+configInterface->isSetFlag(self::IS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getDomSelector(?int $storeId = null): string
+ {
+ return (string) $this->configInterface->getValue(self::DOM_SELECTOR, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getNumberOfProductResults(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::NUMBER_OF_PRODUCT_RESULTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function shouldReplaceCategories(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::REPLACE_CATEGORIES, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getFacets(?int $storeId = null): array
+ {
+ $attrs = $this->serializer->unserialize($this->configInterface->getValue(
+ self::FACETS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ ));
+ if ($attrs) {
+ foreach ($attrs as &$attr) {
+ if ($attr['type'] === 'other') {
+ $attr['type'] = $attr['other_type'];
+ }
+ }
+ if (is_array($attrs)) {
+ return array_values($attrs);
+ }
+ }
+ return [];
+ }
+ public function getMaxValuesPerFacet(?int $storeId = null): int
+ {
+ return (int) $this->configInterface->getValue(
+ self::MAX_VALUES_PER_FACET,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isDynamicFacetsEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::IS_DYNAMIC_FACETS_ENABLED,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ /***
+ * @return array>>
+ */
+ public function getSorting(?int $storeId = null): array
+ {
+ return $this->serializer->unserialize($this->getRawSortingValue($storeId));
+ }
+
+ public function getRawSortingValue(?int $storeId = null): string
+ {
+ return (string) $this->configInterface->getValue(
+ self::SORTING_INDICES,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function setSorting(
+ array $sorting,
+ string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ ?int $scopeId = null
+ ): void
+ {
+ $this->configWriter->save(
+ self::SORTING_INDICES,
+ $this->serializer->serialize($sorting),
+ $scope,
+ $scopeId
+ );
+ }
+
+ public function shouldShowSuggestionsOnNoResultsPage(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::SHOW_SUGGESTIONS_NO_RESULTS,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isSearchBoxEnabled(?int $storeId = null): bool
+ {
+ return $this->isEnabled($storeId)
+ && $this->configInterface->isSetFlag(self::IS_SEARCHBOX_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function isAddToCartEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(
+ self::IS_ADD_TO_CART_ENABLED,
+ ScopeInterface::SCOPE_STORE,
+ $storeId
+ );
+ }
+
+ public function isInfiniteScrollEnabled(?int $storeId = null): bool
+ {
+ return $this->isEnabled($storeId)
+ && $this->configInterface->isSetFlag(
+ self::IS_INFINITE_SCROLL_ENABLED,
+ ScopeInterface::SCOPE_STORE,
+ $storeId);
+ }
+
+ public function shouldHidePagination(?int $storeId = null): bool
+ {
+ return $this->isEnabled($storeId)
+ && $this->configInterface->isSetFlag(self::HIDE_PAGINATION, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function isInstantRedirectEnabled(?int $storeId = null): bool
+ {
+ return $this->configInterface->isSetFlag(self::IS_REDIRECT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
+ }
+
+ public function getInstantRedirectOptions(?int $storeId = null): array
+ {
+ $value = $this->configInterface->getValue(self::REDIRECT_OPTIONS, ScopeInterface::SCOPE_STORE, $storeId);
+ return empty($value) ? [] : explode(',', (string) $value);
+ }
+}
diff --git a/Helper/Configuration/NoticeHelper.php b/Helper/Configuration/NoticeHelper.php
index 9df27fcd6..d3541b638 100644
--- a/Helper/Configuration/NoticeHelper.php
+++ b/Helper/Configuration/NoticeHelper.php
@@ -236,7 +236,7 @@ protected function getPersonalizationNotice()
switch ($personalizationStatus) {
// Activated
case 2: $warningContent = 'Personalization is based on actions a user has performed in the past. We help you collect some of the data automatically.
- After you\'ve collected a reasonable amount of data, Personlization can be applied.';
+ After you\'ve collected a reasonable amount of data, Personalization can be applied.';
$icon = 'icon-warning';
break;
@@ -262,7 +262,7 @@ protected function getPersonalizationNotice()
];
// Adding footer
- $footerContent = '
@@ -53,43 +53,6 @@
]]>
-
- Enable Indexing
- Magento\Config\Model\Config\Source\Yesno
-
-
- The benefit here is that Algolia will manage to keep your data up to date.
- If you choose "No", you will need to push and manage your data in a different way.
- ]]>
-
-
-
- Enable Query Suggestions Index
- Magento\Config\Model\Config\Source\Yesno
-
-
- If you choose "No", _suggestion indexes will not be created.
- ]]>
-
-
- 1
-
-
-
- Enable Pages Index
- Magento\Config\Model\Config\Source\Yesno
-
-
- If you choose "No", _pages indexes will not be created.
- ]]>
-
-
- 1
-
- Enable SearchMagento\Config\Model\Config\Source\Yesno
@@ -327,6 +290,47 @@
+
+ Redirects
+
+
+ Algolia allows you to redirect users
+ to a specific page of your website or mobile app based on a query or a set of conditions.
+
+ ]]>
+
+ 1
+
+ Enable redirects
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+
+
+ Redirect display mode
+ Algolia\AlgoliaSearch\Model\Source\AutocompleteRedirectMode
+
+
+
+ 1
+
+
+ Open redirect URL in a new window
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+ 1,2
+
+
@@ -362,9 +366,6 @@
DOM selector of block in which the search results page will be displayed using JavaScript.
]]>
-
- 1
-
@@ -375,9 +376,6 @@
The number of products displayed on the InstantSearch results page. Default value is 9.
]]>
-
- 1
-
@@ -388,9 +386,6 @@
Do you want to replace default Magento category pages (PLPs) with the InstantSearch results page?
]]>
-
- 1
- Algolia\AlgoliaSearch\Model\Backend\Facets
- - Disjunctive allows a selection of different values per facet (e.g. hotels with 4 OR 5 stars).
- - Conjunctive allows a selection of only one value per facet (e.g. only "Size M").
+ Specify the filtering options you want to offer on a search results page.
+ - Disjunctive facets filter your results on any match (e.g. hotels with 4 OR 5 stars).
+ - Conjunctive facets filter your results on all matches (e.g. shirts that come in "Size M" AND "Size L").
+
Set facet as searchable if you want your customers to be able to search for facet values. It's handy when a facet has a lot of values.
@@ -433,9 +429,26 @@
]]>
-
- 1
-
+
+ Enable dynamic facets
+ Magento\Config\Model\Config\Source\Yesno
+
+
+ This feature utilizes the "Facet display" configuration in the Algolia Dashboard (a.k.a. renderingContent).
+ If you have customized this setting in the Dashboard for your products index, please note that enabling this option will allow Magento to overwrite your configuration.
+
+ ⚠
+ IMPORTANT! Do not enable dynamic facets unless you have the "renderingContent" feature enabled on your Algolia application. Otherwise this configuration
+ can cause your indexing to fail.
+
+ ]]>
+
+
@@ -459,9 +472,6 @@
]]>
-
- 1
-
@@ -516,9 +526,34 @@
]]>
-
- 1
-
+
+
+
+
+ Algolia allows you to redirect users
+ to a specific page of your website or mobile app based on a query or a set of conditions.
+
+ ]]>
+
+ Redirects
+ 1
+
+ Enable redirects
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+
+
+ Redirect options
+ Algolia\AlgoliaSearch\Block\Adminhtml\System\Config\Form\Field\Checkboxes
+ Algolia\AlgoliaSearch\Model\Backend\Checkboxes
+ Algolia\AlgoliaSearch\Model\Source\InstantSearchRedirectOptions
+ 1
+
@@ -580,13 +615,6 @@
]]>
-
- Include non visible products in index
- Magento\Config\Model\Config\Source\Yesno
-
- Include non visible products in index. Default value is No
-
- Category page ID attribute
@@ -599,6 +627,13 @@
1
+
+ Include non visible products in index
+ Magento\Config\Model\Config\Source\Yesno
+
+ Include non visible products in index. Default value is No
+
+
@@ -960,6 +995,31 @@
Algolia\AlgoliaSearch\Model\Config\EnableQueueComment
+
+ Use Magento built-in cron
+ Magento\Config\Model\Config\Source\Yesno
+
+ algolia_queue_process jobs to the Magento cron_schedule table according to the specified cron expression.
+ ]]>
+
+
+ 1
+
+
+
+ Algolia\AlgoliaSearch\Model\Backend\QueueCron
+ Cron expression
+
+ */5 * * * * to process the queue every 5 minutes. You can also use aliases like @hourly.
+ ]]>
+
+
+ 1
+ 1
+
+ validate-digitsNumber of jobs to run each time the cron is run
@@ -984,6 +1044,129 @@
+
+ Indexing Manager
+ algolia
+ Algolia_AlgoliaSearch::algolia_algoliasearch
+
+ Enable Algolia indexing
+ 1
+
+ Enable Indexing
+ Magento\Config\Model\Config\Source\Yesno
+
+
+ The benefit here is that Algolia will manage to keep your data up to date.
+ If you choose "No", you will need to push and manage your data in a different way.
+ ]]>
+
+
+
+ Enable Query Suggestions Index
+ Magento\Config\Model\Config\Source\Yesno
+
+
+ If you choose "No", _suggestion indexes will not be created.
+ ]]>
+
+
+ 1
+
+
+
+ Enable Pages Index
+ Magento\Config\Model\Config\Source\Yesno
+
+
+ If you choose "No", _pages indexes will not be created.
+ ]]>
+
+
+ 1
+
+
+
+
+ Full indexing via Magento indexers
+
+ 1
+
+ 1
+
+ ⚠ Since version 3.16.0, the following Magento indexers can be disabled for full indexing.
+ The extension will continue to rely on them for reindexing specific entities with Magento materialized views or entity save events if you do so.
+
If you want to perform full reindexing, we highly suggest to turn this configuration off and run the newly created CLI commands instead (this will become the default behavior in a future version).
escapeHtml(__('Total searches')) ?>
- getTooltipHtml(__('How many searches were performed. As-you-type searches are aggregated (the queries i, ip, ipa, ipad count as one search).')) ?>
+
= $escaper->escapeHtml(__('Total searches')) ?>
+ = $view->getTooltipHtml(__('How many searches were performed. As-you-type searches are aggregated (the queries i, ip, ipa, ipad count as one search).')) ?>
escapeHtml(__('No results rate')) ?>
- getTooltipHtml(__('Percentage of searches that retrieved 0 results. A lower percentage is better.')); ?>
+
= $escaper->escapeHtml(__('No results rate')) ?>
+ = $view->getTooltipHtml(__('Percentage of searches that retrieved 0 results. A lower percentage is better.')); ?>
escapeHtml(__('Conversion rate')) ?>
- getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful conversion. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
+
= $escaper->escapeHtml(__('Conversion rate')) ?>
+ = $view->getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful conversion. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
- escapeHtml(__('Conversion - Add To Cart')) ?>
- getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful add to cart. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
+ = $escaper->escapeHtml(__('Conversion - Add To Cart')) ?>
+ = $view->getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful add to cart. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
- escapeHtml(__('Conversion - Place Order')) ?>
- getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful purchase. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
+ = $escaper->escapeHtml(__('Conversion - Place Order')) ?>
+ = $view->getTooltipHtml(__('Percentage of tracked searches (searches with clickAnalytics=true) where you signaled to us that it led to a successful purchase. Settings to determine conversion can be found in your Magento Algolia Configuration for Click Analytics.', $view->getAnalyticsConfigurationUrl())) ?>
escapeHtml(__('CTR')) ?>
- getTooltipHtml(__('Click-Through Rate: percentage of tracked searches (searches with clickAnalytics=true) where at least one results was clicked on by the user.')) ?>
+
= $escaper->escapeHtml(__('CTR')) ?>
+ = $view->getTooltipHtml(__('Click-Through Rate: percentage of tracked searches (searches with clickAnalytics=true) where at least one results was clicked on by the user.')) ?>
escapeHtml(__('Click position')) ?>
- getTooltipHtml(__('Average position of the clicks performed on the search results. A value of one would mean all users clicked on the first results. Smaller values are better.')) ?>
+
= $escaper->escapeHtml(__('Click position')) ?>
+ = $view->getTooltipHtml(__('Average position of the clicks performed on the search results. A value of one would mean all users clicked on the first results. Smaller values are better.')) ?>
escapeHtml(__('Popular results')) ?>
- getTooltipHtml(__('Results the most often displayed on the results list after a search.')) ?>
+
= $escaper->escapeHtml(__('Popular results')) ?>
+ = $view->getTooltipHtml(__('Results the most often displayed on the results list after a search.')) ?>
escapeHtml(__('No result searches')) ?>
- getTooltipHtml(__("Searches that retrieved 0 results, either because a word didn't match, or because some filters excluded all of the matching results.
A search with no results can often be optimized by improving keywords used in the dataset, or by adding synonyms.")); ?>
+
= $escaper->escapeHtml(__('No result searches')) ?>
+ = $view->getTooltipHtml(__("Searches that retrieved 0 results, either because a word didn't match, or because some filters excluded all of the matching results.
A search with no results can often be optimized by improving keywords used in the dataset, or by adding synonyms.")); ?>
Enhance your Analytics with Algolia Click Analytics that provide you even more insights
like Click-through Rate, Conversion Rate from searches and average click position.
diff --git a/view/adminhtml/templates/catalog/category/edit/merchandising.phtml b/view/adminhtml/templates/catalog/category/edit/merchandising.phtml
index ed3194c94..4d14c209f 100644
--- a/view/adminhtml/templates/catalog/category/edit/merchandising.phtml
+++ b/view/adminhtml/templates/catalog/category/edit/merchandising.phtml
@@ -1,6 +1,7 @@
getConfigHelper();
@@ -14,7 +15,7 @@ $configHelper = $block->getConfigHelper();
Find out more about Algolia Merchandising, please refer to documentation.
-isRootCategory()) : ?>
+isRootCategory()): ?>
@@ -22,16 +23,17 @@ $configHelper = $block->getConfigHelper();
To merchandise products, please select any sub-category.
To merchandise products using Algolia
you need to enable Instant search with Replace category pages feature.
- You can do it in Algolia's Instant Search configuration.
+ You can do it in Algolia's Instant Search configuration.
Instant search with enabled Replace category pages feature gives your customers a great experience
while browsing your catalog. It enables your customers to search and filter for products at real time resulting
@@ -39,9 +41,10 @@ $configHelper = $block->getConfigHelper();
and enjoy the shopping on your store(s).
Please note that you've selected "Static block only" in Display Settings. Since no products are shown on the page, changes you make with Algolia Merchandising won't be visible to your customers.