From f905c1fd2fdaddd661a5e8e7baaa5b032207323e Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Wed, 24 Feb 2021 14:54:59 +0100 Subject: [PATCH] Release 3.1.0 (#1130) --- .github/CONTRIBUTING.md | 2 +- CHANGELOG.md | 16 + Helper/Entity/CategoryHelper.php | 3 - .../PriceManager/ProductWithoutChildren.php | 2 + Helper/Entity/ProductHelper.php | 6 +- Helper/Image.php | 16 - MAINTAINERS.md | 21 +- Model/Indexer/PageObserver.php | 25 +- README.md | 4 +- Test/Integration/ProductsIndexingTest.php | 38 - composer.json | 2 +- etc/module.xml | 2 +- ...algolia_algoliasearch_landingpage_edit.xml | 1 + view/adminhtml/templates/configuration.phtml | 18 +- view/frontend/templates/autocomplete.phtml | 18 +- view/frontend/web/insights.js | 15 +- .../web/internals/algoliaBundle.min.js | 36 +- .../web/internals/algoliaBundle.min.js.map | 2 +- view/frontend/web/internals/algoliasearch.css | 1454 ----------------- view/frontend/web/internals/autocomplete.css | 13 +- view/frontend/web/internals/common.js | 25 +- .../frontend/web/internals/search-insights.js | 2 +- 22 files changed, 152 insertions(+), 1569 deletions(-) mode change 100755 => 100644 view/frontend/templates/autocomplete.phtml delete mode 100755 view/frontend/web/internals/algoliasearch.css diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 790604354..7b1ed8f0c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -18,8 +18,8 @@ The development team will review all issues and contributions submitted by the c * Integration test coverage * 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 Magento 2.4 * CircleCI [Quality Tools](https://github.com/algolia/magento2-tools) (phpcs and php compatibility) # Contribution process diff --git a/CHANGELOG.md b/CHANGELOG.md index a4e0b7ade..f383f0023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # CHANGE LOG +## 3.1.0 + +### UPDATES +- Fetch Algolia additional data only in the extension's sections in the Magento config (#1119) +- Remove image URL manipulation (#1120) by @fredden +- Add product source hook to modify search options (#1123) +- Use button element for search button (#1102) by @fredden +- Set Price Calculation to true for every tax field during price calculation (#1124) +- Update maintainers.md with process info (#1128) +- Update algoliaBundle with latest instantsearch version (#1127) + +### FIXES +- Fix to keep the price slider values in the filter when user refresh the page (#1121) +- Add missing handle for cms editor layout needed for pagebuilder (#1122) +- Adding credentials check to prevent Magento from crashing on fresh install (#1125) + ## 3.0.2 ### FEATURES diff --git a/Helper/Entity/CategoryHelper.php b/Helper/Entity/CategoryHelper.php index 8b6c3e4cb..827b8d887 100755 --- a/Helper/Entity/CategoryHelper.php +++ b/Helper/Entity/CategoryHelper.php @@ -295,9 +295,6 @@ public function getObject(Category $category) ]; if (!empty($imageUrl)) { - $imageUrl = $this->imageHelper->removeProtocol($imageUrl); - $imageUrl = $this->imageHelper->removeDoubleSlashes($imageUrl); - $data['image_url'] = $imageUrl; } diff --git a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php index 321242e52..e39d2092e 100644 --- a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php +++ b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php @@ -62,6 +62,8 @@ public function addPriceData($customData, Product $product, $subProducts) foreach ($fields as $field => $withTax) { $this->customData[$field] = []; + $product->setPriceCalculation(true); + foreach ($currencies as $currencyCode) { $this->customData[$field][$currencyCode] = []; diff --git a/Helper/Entity/ProductHelper.php b/Helper/Entity/ProductHelper.php index 20feed062..87114dcde 100755 --- a/Helper/Entity/ProductHelper.php +++ b/Helper/Entity/ProductHelper.php @@ -735,11 +735,7 @@ private function addImageData(array $customData, Product $product, $additionalAt $images = $product->getMediaGalleryImages(); if ($images) { foreach ($images as $image) { - $url = $image->getUrl(); - $url = $this->imageHelper->removeProtocol($url); - $url = $this->imageHelper->removeDoubleSlashes($url); - - $customData['media_gallery'][] = $url; + $customData['media_gallery'][] = $image->getUrl(); } } } diff --git a/Helper/Image.php b/Helper/Image.php index 4fa090fca..2350bda40 100755 --- a/Helper/Image.php +++ b/Helper/Image.php @@ -52,9 +52,6 @@ public function getUrl() $url = $this->getDefaultPlaceholderUrl(); } - $url = $this->removeProtocol($url); - $url = $this->removeDoubleSlashes($url); - if ($this->configHelper->shouldRemovePubDirectory()) { $url = $this->removePubDirectory($url); } @@ -110,19 +107,6 @@ private function getConfigurableProductImage() return null; } - public function removeProtocol($url) - { - return str_replace(['https://', 'http://'], '//', $url); - } - - public function removeDoubleSlashes($url) - { - $url = str_replace('//', '/', $url); - $url = '/' . $url; - - return $url; - } - public function removePubDirectory($url) { return str_replace('/pub/', '/', $url); diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 02cd73f76..6954187af 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -1,5 +1,18 @@ -## `algolia/algoliasearch-magento-2` maintainers +# Notes for Maintainers -| Name | Email | -|------------------------------|---------------------------| -| Jan Petr | jan.petr@algolia.com | +### Testing +- CircleCI test configurations are found in the `.circleci/config.yml` file. For any new Magento versions to test against, you will need to build and push up a new image to be used in CircleCI using this [repository](https://github.com/algolia/magento2-circleci). +- Quality tools can also be upgraded [here](https://github.com/algolia/magento2-tools). + +### Approval Process +- All PRs need to have 1 approved reviewer by a maintainer and all testing needs to pass before merging. +- While we have integration testing, we need to manually test all PRs to ensure quality. + +### Release Process +- Prepare release notes with all the changes and tagging community members for their contribution. +- Make a **bump** PR to update all the version numbers and merge into `develop`. +- After a bump has been created, you can then merge `develop` into `master`. +- Create a release and tag with your release notes. + +### Marketplace +You will need to package the release before uploading to the Magento Marketplace. Run `dev/release.sh` in the extension directory to create the zip file. \ No newline at end of file diff --git a/Model/Indexer/PageObserver.php b/Model/Indexer/PageObserver.php index 00b3c57da..6908dd8ec 100644 --- a/Model/Indexer/PageObserver.php +++ b/Model/Indexer/PageObserver.php @@ -2,6 +2,7 @@ namespace Algolia\AlgoliaSearch\Model\Indexer; +use Algolia\AlgoliaSearch\Helper\ConfigHelper; use Magento\Framework\Indexer\IndexerRegistry; use Magento\Framework\Model\AbstractModel; @@ -9,15 +10,29 @@ class PageObserver { private $indexer; - public function __construct(IndexerRegistry $indexerRegistry) - { + /** + * @var ConfigHelper + */ + private $configHelper; + + public function __construct( + IndexerRegistry $indexerRegistry, + ConfigHelper $configHelper + ) { $this->indexer = $indexerRegistry->get('algolia_pages'); + $this->configHelper = $configHelper; } public function beforeSave( \Magento\Cms\Model\ResourceModel\Page $pageResource, AbstractModel $page ) { + if (!$this->configHelper->getApplicationID() + || !$this->configHelper->getAPIKey() + || !$this->configHelper->getSearchOnlyAPIKey()) { + return [$page]; + } + $pageResource->addCommitCallback(function () use ($page) { if (!$this->indexer->isScheduled()) { $this->indexer->reindexRow($page->getId()); @@ -31,6 +46,12 @@ public function beforeDelete( \Magento\Cms\Model\ResourceModel\Page $pageResource, AbstractModel $page ) { + if (!$this->configHelper->getApplicationID() + || !$this->configHelper->getAPIKey() + || !$this->configHelper->getSearchOnlyAPIKey()) { + return [$page]; + } + $pageResource->addCommitCallback(function () use ($page) { if (!$this->indexer->isScheduled()) { $this->indexer->reindexRow($page->getId()); diff --git a/README.md b/README.md index 305290315..e6ea6f98d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Algolia Search for Magento 2 ================== -![Latest version](https://img.shields.io/badge/latest-3.0.2-green.svg) +![Latest version](https://img.shields.io/badge/latest-3.1.0-green.svg) ![Magento 2](https://img.shields.io/badge/Magento-%32.3,%202.4-blue.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) @@ -89,7 +89,7 @@ Knowing the version of the library will help you understand what is available in | --- | --- | --- | --- | | v1.x | [0.26.0](https://github.com/algolia/autocomplete.js/tree/v0.26.0) | [2.10.2](https://github.com/algolia/instantsearch.js/tree/v2.10.2) | [0.0.14](https://cdn.jsdelivr.net/npm/search-insights@0.0.14) | | v2.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) | -| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.7.2](https://github.com/algolia/instantsearch.js/tree/v4.7.2) | [1.4.0](https://github.com/algolia/search-insights.js/tree/v1.4.0) | +| v3.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.15.0](https://github.com/algolia/instantsearch.js/tree/v4.15.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) | The autocomplete and instantsearch libraries are accessible in the `algoliaBundle` global. This bundle is a prepackage javascript file that contains it's dependencies. What is included in this bundle can be seen here: diff --git a/Test/Integration/ProductsIndexingTest.php b/Test/Integration/ProductsIndexingTest.php index 1442a5bf4..24a1acfbc 100644 --- a/Test/Integration/ProductsIndexingTest.php +++ b/Test/Integration/ProductsIndexingTest.php @@ -81,44 +81,6 @@ public function testDefaultIndexableAttributes() $this->assertEmpty($hit, 'Extra products attributes (' . $extraAttributes . ') are indexed and should not be.'); } - public function testNoProtocolImageUrls() - { - $additionAttributes = $this->configHelper->getProductAdditionalAttributes(); - $additionAttributes[] = [ - 'attribute' => 'media_gallery', - 'searchable' => '0', - 'retrievable' => '1', - 'order' => 'unordered', - ]; - - $this->setConfig( - 'algoliasearch_products/products/product_additional_attributes', - $this->getSerializer()->serialize($additionAttributes) - ); - - /** @var Product $indexer */ - $indexer = $this->getObjectManager()->create(Product::class); - $indexer->executeRow($this->getValidTestProduct()); - - $this->algoliaHelper->waitLastTask(); - - $results = $this->algoliaHelper->getObjects($this->indexPrefix . 'default_products', [$this->getValidTestProduct()]); - $hit = reset($results['results']); - - if (!$hit || !array_key_exists('image_url', $hit)) { - $this->markTestIncomplete('Hit was not returned correctly from Algolia. No Hit to run assetions on.'); - } - - $this->assertStringStartsWith('//', $hit['image_url']); - $this->assertStringStartsWith('//', $hit['thumbnail_url']); - - $this->assertArrayHasKey('media_gallery', $hit); - - foreach ($hit['media_gallery'] as $galleryImageUrl) { - $this->assertStringStartsWith('//', $galleryImageUrl); - } - } - public function testNoSpecialPrice() { /** @var Product $indexer */ diff --git a/composer.json b/composer.json index c444ab53e..6fe02eecf 100755 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Algolia Search integration for Magento 2", "type": "magento2-module", "license": ["MIT"], - "version": "3.0.2", + "version": "3.1.0", "require": { "magento/framework": "~102.0|~103.0", "algolia/algoliasearch-client-php": "^2.4", diff --git a/etc/module.xml b/etc/module.xml index 7538d0cb2..887b13ede 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/adminhtml/layout/algolia_algoliasearch_landingpage_edit.xml b/view/adminhtml/layout/algolia_algoliasearch_landingpage_edit.xml index 996a4f80d..5ccf46201 100644 --- a/view/adminhtml/layout/algolia_algoliasearch_landingpage_edit.xml +++ b/view/adminhtml/layout/algolia_algoliasearch_landingpage_edit.xml @@ -1,6 +1,7 @@ + diff --git a/view/adminhtml/templates/configuration.phtml b/view/adminhtml/templates/configuration.phtml index 922ef651c..7067797fb 100755 --- a/view/adminhtml/templates/configuration.phtml +++ b/view/adminhtml/templates/configuration.phtml @@ -9,14 +9,20 @@ $isClickAnalyticsEnabled = true; $section = $block->getRequest()->getParam('section'); -if ($section === 'algoliasearch_cc_analytics') { - $isClickAnalyticsEnabled = $viewModel->isClickAnalyticsEnabled(); +$linksAndVideoTemplate = ''; +$extensionNotices = []; +$personalizationStatus = 0; + +if (preg_match('/algoliasearch_/', $section)) { + if ($section === 'algoliasearch_cc_analytics') { + $isClickAnalyticsEnabled = $viewModel->isClickAnalyticsEnabled(); + } + + $linksAndVideoTemplate = $viewModel->getLinksAndVideoTemplate($section); + $extensionNotices = $viewModel->getExtensionNotices(); + $personalizationStatus = $viewModel->getPersonalizationStatus(); } -$linksAndVideoTemplate = $viewModel->getLinksAndVideoTemplate($section); -$extensionNotices = $viewModel->getExtensionNotices(); -$personalizationStatus = $viewModel->getPersonalizationStatus(); - ?>