diff --git a/.circleci/config.yml b/.circleci/config.yml
index 309338d22..d149e6977 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -76,19 +76,16 @@ jobs:
sudo chown circleci:circleci ~/.composer/
- restore_cache:
keys:
- - composer-v2-{{ checksum "composer.json" }}
- - composer-v2-
+ - composer-v3-{{ checksum "composer.json" }}
+ - composer-v3-
- run:
name: Prepare environment
command: |
- sudo composer self-update
- composer config http-basic.'repo.magento.com' ${MAGENTO_AUTH_USERNAME} ${MAGENTO_AUTH_PASSWORD}
- composer install -n --prefer-dist --ignore-platform-reqs --no-progress
sudo chown circleci:circleci ~/.composer/
composer global config prefer-stable true
composer global config minimum-stability dev
- composer global require algolia/magento2-tools --ignore-platform-reqs
+ composer global require algolia/magento2-tools
# We have to do this again because we restore the cache above, overwriting the vendor with the original.
cd ~/magento_directory/vendor/algolia
@@ -97,10 +94,9 @@ jobs:
cd ~/magento_directory
composer dump-autoload
- save_cache:
- key: composer-v2-{{ checksum "composer.json" }}
+ key: composer-v3-{{ checksum "composer.json" }}
paths:
- vendor
- - ~/.composer/vendor
- run:
name: Quality tools
command: |
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 504c71dfe..790604354 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -16,8 +16,11 @@ The development team will review all issues and contributions submitted by the c
4. PRs which include bug fixing, must be accompanied with step-by-step description of how to reproduce the bug.
5. PRs which include new logic or new features must be submitted along with:
* Integration test coverage
- * Proposed [documentation](https://community.algolia.com/magento/) update. Documentation contributions can be submitted [here](https://github.com/algolia/magento).
-6. All automated tests are passed successfully (all builds on [Travis CI](https://travis-ci.org/algolia/algoliasearch-magento-2/) must be green).
+ * Proposed [documentation](https://www.algolia.com/doc/integration/magento-2/getting-started/quick-start/) update
+6. All automated tests are passed successfully:
+ * CircleCI Magento 2.2
+ * CircleCI Magento 2.3
+ * CircleCI [Quality Tools](https://github.com/algolia/magento2-tools) (phpcs and php compatibility)
# Contribution process
@@ -35,7 +38,7 @@ If you are a new GitHub user, we recommend that you create your own [free github
# Continuous Integration checks
-Automated continous integration checks are run on [Travis CI](https://travis-ci.org/algolia/algoliasearch-magento-2/).
+Automated continous integration checks are run on [CircleCI](../.circleci/config.yml).
## Integration tests
@@ -152,3 +155,29 @@ $ composer create-project --repository=https://repo.magento.com magento/marketpl
```bash
[[magento-coding-standard_dir]]/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit true --ignore=dev,Test [[magento_root_dir]]/vendor/algolia/algoliasearch-magento-2 --standard=MEQP2 --extensions=php,phtml
```
+
+## Quality Tools
+As an alternative to testing Code Styling and Static Analysis individually, you can use our [Quality Tools](https://github.com/algolia/magento2-tools) tool that our CircleCI integration check against, to lint and test your changes.
+
+You can install the tool via composer:
+```bash
+composer global require algolia/magento2-tools
+```
+
+Make sure to place Composer's system-wide vendor bin directory in your `$PATH` so the `magento2-tool` executable can be located by your system.
+
+Finally, you can launch the quality tools with:
+```bash
+{command} path/to/magento/extension
+```
+
+Here is the list of available commands:
+
+- **`magento2-lint`**: Runs the linter and fixes the found issues - configuration file under `algoliasearch-magento-2/.php_cs`.
+
+- **`magento2-types`**: Runs the type checker and displays the found issues - configuration file under `algoliasearch-magento-2/phpstan.neon`.
+
+- **`magento2-php-compatibility`**: Checks if your code is compatibility between multiple all php versions supported by magento.
+
+- **`magento2-test`**: Runs all previous commands in `--dry-run` mode.
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9eaf193bb..ec21bcc44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,25 @@
# CHANGE LOG
+## 1.13.2
+
+### UPDATES
+- Update copyQueryRules to use client scopedCopyIndex (#1030)
+- Removed obsolete trigger for catalog_product_entity_media_gallery from mview.xml (#1025) @vmalyk
+- Added CSP whitelisted hosts for Magento 2.3.5 or higher (#1036) @vmalyk
+- Refactor getSalesData() method for optimisation (#1041)
+- Add filterPromotes to true for query rules (#1045)
+- Add category_without_path only if categories is searchable (#969) (#1051) @VincentMarmiesse
+
+### FIXES
+- Prevent division by zero in the Notice Helper when configuration is not set (#1031) @vmalyk
+- Fix ProductHelper for bundle subproducts error (#1014)
+- Check the right storeId for moveIndex (#1016) (#1051) @palviggi-flagbit
+
+### TOOLING
+- Circleci do not use cache on the global composer vendor (#997) (#1028)
+- Remove composer self-update from circleCI quality tools (#1032) (#1052)
+- Update CircleCI quality tools to remove composer set and install (#1033) (#1052)
+
## 1.13.1
### UPDATES
diff --git a/Helper/AlgoliaHelper.php b/Helper/AlgoliaHelper.php
index 4077807fe..18bcc11e7 100755
--- a/Helper/AlgoliaHelper.php
+++ b/Helper/AlgoliaHelper.php
@@ -351,40 +351,15 @@ public function copySynonyms($fromIndexName, $toIndexName)
/**
* @param $fromIndexName
* @param $toIndexName
- *
- * @throws AlgoliaException
*/
public function copyQueryRules($fromIndexName, $toIndexName)
{
- $fromIndex = $this->getIndex($fromIndexName);
- $toIndex = $this->getIndex($toIndexName);
-
- $queryRulesToSet = [];
-
- $hitsPerPage = 100;
- $page = 0;
- do {
- $fetchedQueryRules = $fromIndex->searchRules([
- 'page' => $page,
- 'hitsPerPage' => $hitsPerPage,
- ]);
+ $res = $this->getClient()->scopedCopyIndex($fromIndexName, $toIndexName, ['rules'], [
+ 'forwardToReplicas' => true,
+ 'clearExistingRules' => true,
+ ]);
- foreach ($fetchedQueryRules['hits'] as $hit) {
- unset($hit['_highlightResult']);
-
- $queryRulesToSet[] = $hit;
- }
-
- $page++;
- } while (($page * $hitsPerPage) < $fetchedQueryRules['nbHits']);
-
- if (!$queryRulesToSet) {
- $res = $toIndex->clearRules(true);
- } else {
- $res = $toIndex->batchRules($queryRulesToSet, true, true);
- }
-
- self::$lastUsedIndexName= $toIndex;
+ self::$lastUsedIndexName = $toIndexName;
self::$lastTaskId = $res['taskID'];
}
diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php
index ddc8032af..97096255e 100755
--- a/Helper/ConfigHelper.php
+++ b/Helper/ConfigHelper.php
@@ -389,7 +389,9 @@ public function getNumberOfElementByPage($storeId = null)
public function getNumberOfJobToRun($storeId = null)
{
- return (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
+ $nbJobs = (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
+
+ return max($nbJobs, 1);
}
public function getRetryLimit($storeId = null)
diff --git a/Helper/Data.php b/Helper/Data.php
index 941154ab1..8d4ed45a2 100755
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -739,24 +739,29 @@ private function getSalesData($storeId, Collection $collection)
return [];
}
- $ordersTableName = $this->resource->getTableName('sales_order_item');
+ $salesData = [];
$ids = $collection->getColumnValues('entity_id');
- $ids[] = '0'; // Makes sure the imploded string is not empty
- $ids = implode(', ', $ids);
+ if (count($ids)) {
+ $ordersTableName = $this->resource->getTableName('sales_order_item');
- try {
- $salesConnection = $this->resource->getConnectionByName('sales');
- } catch (\DomainException $e) {
- $salesConnection = $this->resource->getConnection();
- }
+ try {
+ $salesConnection = $this->resource->getConnectionByName('sales');
+ } catch (\DomainException $e) {
+ $salesConnection = $this->resource->getConnection();
+ }
+
+ $select = $salesConnection->select()
+ ->from($ordersTableName, [])
+ ->columns('product_id')
+ ->columns(['ordered_qty' => new \Zend_Db_Expr('SUM(qty_ordered)')])
+ ->columns(['total_ordered' => new \Zend_Db_Expr('SUM(row_total)')])
+ ->where('product_id IN (?)', $ids)
+ ->group('product_id');
- $query = 'SELECT product_id, SUM(qty_ordered) AS ordered_qty, SUM(row_total) AS total_ordered
- FROM ' . $ordersTableName . '
- WHERE product_id IN (' . $ids . ')
- GROUP BY product_id';
- $salesData = $salesConnection->query($query)->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_UNIQUE|\PDO::FETCH_ASSOC);
+ $salesData = $salesConnection->fetchAll($select, [], \PDO::FETCH_GROUP|\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
+ }
return $salesData;
}
diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php
index 85c60712a..dd27c058f 100755
--- a/Helper/Entity/ProductHelper.php
+++ b/Helper/Entity/ProductHelper.php
@@ -550,7 +550,7 @@ private function getSubProducts(Product $product)
if ($typeInstance instanceof Configurable) {
$subProducts = $typeInstance->getUsedProducts($product);
} elseif ($typeInstance instanceof BundleProductType) {
- $subProducts = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
+ $subProducts = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product)->getItems();
} else { // Grouped product
$subProducts = $typeInstance->getAssociatedProducts($product);
}
@@ -929,11 +929,11 @@ private function getSearchableAttributes($storeId = null)
} else {
$searchableAttributes[] = 'unordered(' . $attribute['attribute'] . ')';
}
- }
- if ($attribute['attribute'] === 'categories') {
- $searchableAttributes[] = (isset($attribute['order']) && $attribute['order'] === 'ordered') ?
- 'categories_without_path' : 'unordered(categories_without_path)';
+ if ($attribute['attribute'] === 'categories') {
+ $searchableAttributes[] = (isset($attribute['order']) && $attribute['order'] === 'ordered') ?
+ 'categories_without_path' : 'unordered(categories_without_path)';
+ }
}
}
diff --git a/Helper/MerchandisingHelper.php b/Helper/MerchandisingHelper.php
index abea5460e..a097c576e 100755
--- a/Helper/MerchandisingHelper.php
+++ b/Helper/MerchandisingHelper.php
@@ -45,6 +45,7 @@ public function saveQueryRule($storeId, $entityId, $rawPositions, $entityType, $
'context' => 'magento-' . $entityType . '-' . $entityId,
],
'consequence' => [
+ 'filterPromotes' => true,
'promote' => $positions,
],
];
diff --git a/Model/IndexMover.php b/Model/IndexMover.php
index 6b1298424..dc99cc473 100644
--- a/Model/IndexMover.php
+++ b/Model/IndexMover.php
@@ -35,10 +35,11 @@ public function __construct(
/**
* @param string $tmpIndexName
* @param string $indexName
+ * @param int $storeId
*/
- public function moveIndex($tmpIndexName, $indexName)
+ public function moveIndex($tmpIndexName, $indexName, $storeId)
{
- if ($this->baseHelper->isIndexingEnabled() === false) {
+ if ($this->baseHelper->isIndexingEnabled($storeId) === false) {
return;
}
@@ -48,17 +49,17 @@ public function moveIndex($tmpIndexName, $indexName)
/**
* @param string $tmpIndexName
* @param string $indexName
- * @param int $storeId
+ * @param int $storeId
*
* @throws AlgoliaException
*/
public function moveIndexWithSetSettings($tmpIndexName, $indexName, $storeId)
{
- if ($this->baseHelper->isIndexingEnabled() === false) {
+ if ($this->baseHelper->isIndexingEnabled($storeId) === false) {
return;
}
$this->indicesConfigurator->saveConfigurationToAlgolia($storeId, true);
- $this->moveIndex($tmpIndexName, $indexName);
+ $this->moveIndex($tmpIndexName, $indexName, $storeId);
}
}
diff --git a/README.md b/README.md
index 2d598fc82..335ebfd59 100755
--- a/README.md
+++ b/README.md
@@ -1,30 +1,30 @@
Algolia Search for Magento 2
==================
-![Latest version](https://img.shields.io/badge/latest-1.13.1-green.svg)
-![Magento 2](https://img.shields.io/badge/Magento-%3E=2.2-blue.svg)
+![Latest version](https://img.shields.io/badge/latest-1.13.2-green.svg)
+![Magento 2](https://img.shields.io/badge/Magento-%3E=2.2%20<2.4-blue.svg)
![PHP >= 7.0.6](https://img.shields.io/badge/PHP-%3E=7.0-green.svg)
[![CircleCI](https://circleci.com/gh/algolia/algoliasearch-magento-2/tree/master.svg?style=svg)](https://circleci.com/gh/algolia/algoliasearch-magento-2/tree/master)
-------
-🔎 Are you a Magento engineer? [Join our team](https://www.algolia.com/careers#!?j=eed58660-f684-436d-a2ff-e9947d2b65a2) and help us deliver the best search solution for Magento stores!
+🔎 **Need help?** Check out our [Technical Troubleshooting Guide](https://www.algolia.com/doc/integration/magento-2/troubleshooting/technical-troubleshooting/). For feedback, bug reporting, or unresolved issues with the extension, please contact us at [support@algolia.com](mailto:support@algolia.com). Please include your Magento version, extension version, application ID, and steps to reproducing your issue. Add additional information like screenshots, screencasts, and error messages to help our team better troubleshoot your issues.
-------
-- **Auto-completion menu:** Offer End-Users immediate access to your whole catalog from the dropdown menu, whatever your number of categories or attributes.
+- **Autocompletion menu:** Offer End-Users immediate access to your whole catalog from the dropdown menu, whatever your number of categories or attributes.
-- **Instant search results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke.
+- **Instantsearch results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke.
-Official website: [community.algolia.com/magento](https://community.algolia.com/magento).
+Official website: [https://www.algolia.com/solutions/magento/](https://www.algolia.com/solutions/magento/).
*Note: if your store is running under Magento version 1.x, please check our [Algolia for Magento 1 extension](https://github.com/algolia/algoliasearch-magento).*
Demo
--------------
-Try the auto-complete and the instant search results page on our [live demo](https://magento2.algolia.com).
+Try the autocomplete and the instantsearch results page on our [live demo](https://magento2.algolia.com).
Algolia Search
--------------
@@ -33,11 +33,6 @@ Algolia Search
This extension replaces the default search of Magento with a typo-tolerant, fast & relevant search experience backed by Algolia. It's based on [algoliasearch-client-php](https://github.com/algolia/algoliasearch-client-php), [autocomplete.js](https://github.com/algolia/autocomplete.js) and [instantsearch.js](https://github.com/algolia/instantsearch.js).
-
-
Documentation
--------------
@@ -58,4 +53,17 @@ Run the following commands:
Contribution
------------
-To start contribuiting to the extension follow the [contributing guildelines](.github/CONTRIBUTING.md).
+To start contributing to the extension follow the [contributing guildelines](.github/CONTRIBUTING.md).
+
+Need Help?
+------------
+Here are some helpful documentation to help with your issue:
+
+- [General FAQs](https://www.algolia.com/doc/integration/magento-2/troubleshooting/general-faq/)
+- [Technical Troubleshooting Guide](https://www.algolia.com/doc/integration/magento-2/troubleshooting/technical-troubleshooting/)
+- [Indexing Queue](https://www.algolia.com/doc/integration/magento-2/how-it-works/indexing-queue/)
+- [Frontend Custom Events](https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/)
+- [Dispatched Backend Events](https://www.algolia.com/doc/integration/magento-2/customize/custom-back-end-events/)
+
+For feedback, bug reporting, or unresolved issues with the extension, please contact us at [support@algolia.com](mailto:support@algolia.com). Please include your Magento version, extension version, application ID, and steps to reproducing your issue. Add additional information like screenshots, screencasts, and error messages to help our team better troubleshoot your issues.
+
diff --git a/composer.json b/composer.json
index 8484b0e7d..47ee0ece7 100755
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
"description": "Algolia Search integration for Magento 2",
"type": "magento2-module",
"license": ["MIT"],
- "version": "1.13.1",
+ "version": "1.13.2",
"require": {
"php": "~7.0|~7.1|~7.2|~7.3",
"magento/framework": "~101.0|~102.0",
diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml
new file mode 100644
index 000000000..6c29bb921
--- /dev/null
+++ b/etc/csp_whitelist.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+ polyfill.io
+
+
+
+
+ *.algolia.net
+
+
+
+
\ No newline at end of file
diff --git a/etc/module.xml b/etc/module.xml
index a887ab2e2..783ebf8ee 100755
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/etc/mview.xml b/etc/mview.xml
index b968d66a9..23e3ba204 100755
--- a/etc/mview.xml
+++ b/etc/mview.xml
@@ -27,7 +27,6 @@
-