Skip to content

Commit d7d6ba2

Browse files
authored
Release 2.0.1 (#1056)
### UPDATES - Update the copyQueryRules method to use api client copyRules (#1029) - Removed obsolete trigger for catalog_product_entity_media_gallery from mview.xml (#1027) @vmalyk - Add csp_whitelist for services (#1039) - Refactor getSalesData() method for optimisation (#1034) - Activate "filterPromotes" attribute for created Merchandising Rules (#1043) - Add category_without_path only if categories is searchable (#969) @VincentMarmiesse ### FIXES - Prevent division by zero in the Notice Helper when configuration is not set (#1026) - Remove extra css import (#1013) @palviggi-flagbit - Bundle products collection to return getItems array (#1038) - Switch from priceRanges to input ranges widget for ISV4 (#1042) - Check the right storeId for moveIndex (#1016) @palviggi-flagbit ### TOOLING - Remove composer self-update from circleCI quality tools (#1032) - Update CircleCI quality tools to remove composer set and install (#1033)
1 parent 0192141 commit d7d6ba2

File tree

17 files changed

+135
-86
lines changed

17 files changed

+135
-86
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ jobs:
7777
- run:
7878
name: Prepare environment
7979
command: |
80-
sudo composer self-update
81-
composer config http-basic.'repo.magento.com' ${MAGENTO_AUTH_USERNAME} ${MAGENTO_AUTH_PASSWORD}
82-
composer install -n --prefer-dist --no-progress
8380
sudo chown circleci:circleci ~/.composer/
8481
composer global config prefer-stable true
8582
composer global config minimum-stability dev

.github/CONTRIBUTING.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ The development team will review all issues and contributions submitted by the c
1616
4. PRs which include bug fixing, must be accompanied with step-by-step description of how to reproduce the bug.
1717
5. PRs which include new logic or new features must be submitted along with:
1818
* Integration test coverage
19-
* Proposed [documentation](https://community.algolia.com/magento/) update. Documentation contributions can be submitted [here](https://github.com/algolia/magento).
20-
6. All automated tests are passed successfully (all builds on [Travis CI](https://travis-ci.org/algolia/algoliasearch-magento-2/) must be green).
19+
* Proposed [documentation](https://www.algolia.com/doc/integration/magento-2/getting-started/quick-start/) update
20+
6. All automated tests are passed successfully:
21+
* CircleCI Magento 2.2
22+
* CircleCI Magento 2.3
23+
* CircleCI [Quality Tools](https://github.com/algolia/magento2-tools) (phpcs and php compatibility)
2124

2225
# Contribution process
2326

@@ -35,7 +38,7 @@ If you are a new GitHub user, we recommend that you create your own [free github
3538

3639
# Continuous Integration checks
3740

38-
Automated continous integration checks are run on [Travis CI](https://travis-ci.org/algolia/algoliasearch-magento-2/).
41+
Automated continous integration checks are run on [CircleCI](../.circleci/config.yml).
3942

4043
## Integration tests
4144

@@ -152,3 +155,29 @@ $ composer create-project --repository=https://repo.magento.com magento/marketpl
152155
```bash
153156
[[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
154157
```
158+
159+
## Quality Tools
160+
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.
161+
162+
You can install the tool via composer:
163+
```bash
164+
composer global require algolia/magento2-tools
165+
```
166+
167+
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.
168+
169+
Finally, you can launch the quality tools with:
170+
```bash
171+
{command} path/to/magento/extension
172+
```
173+
174+
Here is the list of available commands:
175+
176+
- **`magento2-lint`**: Runs the linter and fixes the found issues - configuration file under `algoliasearch-magento-2/.php_cs`.
177+
178+
- **`magento2-types`**: Runs the type checker and displays the found issues - configuration file under `algoliasearch-magento-2/phpstan.neon`.
179+
180+
- **`magento2-php-compatibility`**: Checks if your code is compatibility between multiple all php versions supported by magento.
181+
182+
- **`magento2-test`**: Runs all previous commands in `--dry-run` mode.
183+

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# CHANGE LOG
22

3+
## 2.0.1
4+
5+
### UPDATES
6+
- Update the copyQueryRules method to use api client copyRules (#1029)
7+
- Removed obsolete trigger for catalog_product_entity_media_gallery from mview.xml (#1027) @vmalyk
8+
- Add csp_whitelist for services (#1039)
9+
- Refactor getSalesData() method for optimisation (#1034)
10+
- Activate "filterPromotes" attribute for created Merchandising Rules (#1043)
11+
- Add category_without_path only if categories is searchable (#969) @VincentMarmiesse
12+
13+
### FIXES
14+
- Prevent division by zero in the Notice Helper when configuration is not set (#1026)
15+
- Remove extra css import (#1013) @palviggi-flagbit
16+
- Bundle products collection to return getItems array (#1038)
17+
- Switch from priceRanges to input ranges widget for ISV4 (#1042)
18+
- Check the right storeId for moveIndex (#1016) @palviggi-flagbit
19+
20+
21+
### TOOLING
22+
- Remove composer self-update from circleCI quality tools (#1032)
23+
- Update CircleCI quality tools to remove composer set and install (#1033)
24+
325
## 2.0.0
426
With the release of a new major version, we have decided to create minor and major version releases to allow those that want to continue on the minor version. This update will **break compatibility**. Please read the [upgrade guide](https://www.algolia.com/doc/integration/magento-2/getting-started/upgrading/#upgrading-from-v1-to-v2) for all of the file changes and updates included in this release.
527

@@ -638,4 +660,4 @@ Since this release, the extension is **Enterprise Edition compliant**!
638660

639661
## 0.8.0
640662

641-
Initial stable release
663+
Initial stable release

Helper/AlgoliaHelper.php

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -398,44 +398,15 @@ public function copySynonyms($fromIndexName, $toIndexName)
398398
* @param $fromIndexName
399399
* @param $toIndexName
400400
*
401-
* @throws AlgoliaException
402401
*/
403402
public function copyQueryRules($fromIndexName, $toIndexName)
404403
{
405-
$fromIndex = $this->getIndex($fromIndexName);
406-
$toIndex = $this->getIndex($toIndexName);
407-
408-
$queryRulesToSet = [];
409-
410-
$hitsPerPage = 100;
411-
$page = 0;
412-
do {
413-
$fetchedQueryRules = $fromIndex->searchRules('', [
414-
'page' => $page,
415-
'hitsPerPage' => $hitsPerPage,
416-
]);
417-
418-
foreach ($fetchedQueryRules['hits'] as $hit) {
419-
unset($hit['_highlightResult']);
420-
421-
$queryRulesToSet[] = $hit;
422-
}
423-
424-
$page++;
425-
} while (($page * $hitsPerPage) < $fetchedQueryRules['nbHits']);
426-
427-
if (!$queryRulesToSet) {
428-
$res = $toIndex->clearRules([
429-
'forwardToReplicas' => true,
430-
]);
431-
} else {
432-
$res = $toIndex->saveRules($queryRulesToSet, [
433-
'forwardToReplicas' => true,
434-
'clearExistingRules' => true,
435-
]);
436-
}
404+
$res = $this->getClient()->copyRules($fromIndexName, $toIndexName, [
405+
'forwardToReplicas' => true,
406+
'clearExistingRules' => true,
407+
]);
437408

438-
self::setLastOperationInfo($toIndex, $res);
409+
self::setLastOperationInfo($toIndexName, $res);
439410
}
440411

441412
private function checkClient($methodName)

Helper/ConfigHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ public function getNumberOfElementByPage($storeId = null)
389389

390390
public function getNumberOfJobToRun($storeId = null)
391391
{
392-
return (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
392+
$nbJobs = (int) $this->configInterface->getValue(self::NUMBER_OF_JOB_TO_RUN, ScopeInterface::SCOPE_STORE, $storeId);
393+
394+
return max($nbJobs, 1);
393395
}
394396

395397
public function getRetryLimit($storeId = null)

Helper/Data.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -739,24 +739,29 @@ private function getSalesData($storeId, Collection $collection)
739739
return [];
740740
}
741741

742-
$ordersTableName = $this->resource->getTableName('sales_order_item');
742+
$salesData = [];
743743

744744
$ids = $collection->getColumnValues('entity_id');
745-
$ids[] = '0'; // Makes sure the imploded string is not empty
746745

747-
$ids = implode(', ', $ids);
746+
if (count($ids)) {
747+
$ordersTableName = $this->resource->getTableName('sales_order_item');
748748

749-
try {
750-
$salesConnection = $this->resource->getConnectionByName('sales');
751-
} catch (\DomainException $e) {
752-
$salesConnection = $this->resource->getConnection();
753-
}
749+
try {
750+
$salesConnection = $this->resource->getConnectionByName('sales');
751+
} catch (\DomainException $e) {
752+
$salesConnection = $this->resource->getConnection();
753+
}
754+
755+
$select = $salesConnection->select()
756+
->from($ordersTableName, [])
757+
->columns('product_id')
758+
->columns(['ordered_qty' => new \Zend_Db_Expr('SUM(qty_ordered)')])
759+
->columns(['total_ordered' => new \Zend_Db_Expr('SUM(row_total)')])
760+
->where('product_id IN (?)', $ids)
761+
->group('product_id');
754762

755-
$query = 'SELECT product_id, SUM(qty_ordered) AS ordered_qty, SUM(row_total) AS total_ordered
756-
FROM ' . $ordersTableName . '
757-
WHERE product_id IN (' . $ids . ')
758-
GROUP BY product_id';
759-
$salesData = $salesConnection->query($query)->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_UNIQUE|\PDO::FETCH_ASSOC);
763+
$salesData = $salesConnection->fetchAll($select, [], \PDO::FETCH_GROUP|\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE);
764+
}
760765

761766
return $salesData;
762767
}

Helper/Entity/ProductHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ private function getSubProducts(Product $product)
550550
if ($typeInstance instanceof Configurable) {
551551
$subProducts = $typeInstance->getUsedProducts($product);
552552
} elseif ($typeInstance instanceof BundleProductType) {
553-
$subProducts = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
553+
$subProducts = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product)->getItems();
554554
} else { // Grouped product
555555
$subProducts = $typeInstance->getAssociatedProducts($product);
556556
}
@@ -929,11 +929,11 @@ private function getSearchableAttributes($storeId = null)
929929
} else {
930930
$searchableAttributes[] = 'unordered(' . $attribute['attribute'] . ')';
931931
}
932-
}
933932

934-
if ($attribute['attribute'] === 'categories') {
935-
$searchableAttributes[] = (isset($attribute['order']) && $attribute['order'] === 'ordered') ?
936-
'categories_without_path' : 'unordered(categories_without_path)';
933+
if ($attribute['attribute'] === 'categories') {
934+
$searchableAttributes[] = (isset($attribute['order']) && $attribute['order'] === 'ordered') ?
935+
'categories_without_path' : 'unordered(categories_without_path)';
936+
}
937937
}
938938
}
939939

Helper/MerchandisingHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function saveQueryRule($storeId, $entityId, $rawPositions, $entityType, $
4545
'context' => 'magento-' . $entityType . '-' . $entityId,
4646
],
4747
'consequence' => [
48+
'filterPromotes' => true,
4849
'promote' => $positions,
4950
],
5051
];

Model/IndexMover.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ public function __construct(
3535
/**
3636
* @param string $tmpIndexName
3737
* @param string $indexName
38+
* @param int $storeId
3839
*/
39-
public function moveIndex($tmpIndexName, $indexName)
40+
public function moveIndex($tmpIndexName, $indexName, $storeId)
4041
{
41-
if ($this->baseHelper->isIndexingEnabled() === false) {
42+
if ($this->baseHelper->isIndexingEnabled($storeId) === false) {
4243
return;
4344
}
4445

@@ -48,17 +49,17 @@ public function moveIndex($tmpIndexName, $indexName)
4849
/**
4950
* @param string $tmpIndexName
5051
* @param string $indexName
51-
* @param int $storeId
52+
* @param int $storeId
5253
*
5354
* @throws AlgoliaException
5455
*/
5556
public function moveIndexWithSetSettings($tmpIndexName, $indexName, $storeId)
5657
{
57-
if ($this->baseHelper->isIndexingEnabled() === false) {
58+
if ($this->baseHelper->isIndexingEnabled($storeId) === false) {
5859
return;
5960
}
6061

6162
$this->indicesConfigurator->saveConfigurationToAlgolia($storeId, true);
62-
$this->moveIndex($tmpIndexName, $indexName);
63+
$this->moveIndex($tmpIndexName, $indexName, $storeId);
6364
}
6465
}

Model/Source/Facets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function getTableData()
5050
'conjunctive' => 'Conjunctive',
5151
'disjunctive' => 'Disjunctive',
5252
'slider' => 'Slider',
53-
'priceRanges' => 'Price Ranges',
53+
'priceRanges' => 'Price Range',
5454
],
5555
],
5656
'label' => [

0 commit comments

Comments
 (0)