Skip to content

Commit

Permalink
Release 3.1.0 (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou authored Feb 24, 2021
1 parent 4762fe2 commit f905c1f
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 1,569 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions Helper/Entity/CategoryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions Helper/Entity/Product/PriceManager/ProductWithoutChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [];

Expand Down
6 changes: 1 addition & 5 deletions Helper/Entity/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 17 additions & 4 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## `algolia/algoliasearch-magento-2` maintainers
# Notes for Maintainers

| Name | Email |
|------------------------------|---------------------------|
| Jan Petr | [email protected] |
### 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.
25 changes: 23 additions & 2 deletions Model/Indexer/PageObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@

namespace Algolia\AlgoliaSearch\Model\Indexer;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\AbstractModel;

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());
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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/[email protected]) |
| 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:

Expand Down
38 changes: 0 additions & 38 deletions Test/Integration/ProductsIndexingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Algolia_AlgoliaSearch" setup_version="3.0.2">
<module name="Algolia_AlgoliaSearch" setup_version="3.1.0">
<sequence>
<module name="Magento_Theme"/>
<module name="Magento_Backend"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="editor"/>
<head>
<css src="Algolia_AlgoliaSearch::css/landing-page.css"/>
</head>
Expand Down
18 changes: 12 additions & 6 deletions view/adminhtml/templates/configuration.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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();

?>

<script>
Expand Down
18 changes: 13 additions & 5 deletions view/frontend/templates/autocomplete.phtml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php
/** @var \Algolia\AlgoliaSearch\Block\Algolia $block */
/**
* @var \Algolia\AlgoliaSearch\Block\Algolia $block
*/

$config = $block->getConfigHelper();

$catalogSearchHelper = $block->getCatalogSearchHelper();

$placeholder = __('Search for products, categories, ...');

/** Render form with autocomplete input **/
// Render form with autocomplete input
if ($config->isDefaultSelector()) : ?>
<div class="block block-search algolia-search-block">
<div class="block block-title"><strong><?php echo $block->escapeHtml(__('Search')); ?></strong></div>
Expand All @@ -26,12 +28,18 @@ if ($config->isDefaultSelector()) : ?>
spellcheck="false"
autocorrect="off"
autocapitalize="off"
placeholder="<?php echo $block->escapeHtml($placeholder); ?>" />
placeholder="<?php echo $block->escapeHtml($placeholder); ?>"
/>

<span class="clear-cross clear-query-autocomplete"></span>
<span id="algolia-glass" class="magnifying-glass" width="24" height="24"></span>
<button id="algolia-glass"
class="magnifying-glass"
type="submit"
title="<?php echo $block->escapeHtmlAttr(__('Search')); ?>"
width="24"
height="24"></button>
</div>
</form>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
15 changes: 13 additions & 2 deletions view/frontend/web/insights.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ requirejs([
'jquery',
'algoliaAnalytics',
'algoliaBundle',
], function ($, algoliaAnalytics, algoliaBundle) {
], function ($, algoliaAnalyticsWrapper, algoliaBundle) {

algoliaAnalytics = algoliaAnalyticsWrapper.default;

var algoliaInsights = {
config: null,
defaultIndexName: null,
isTracking: false,
hasAddedParameters: false,

track: function(algoliaConfig) {

Expand Down Expand Up @@ -46,7 +49,10 @@ requirejs([

addSearchParameters: function() {

var self = this;
if (this.hasAddedParameters) {
return;
}

algolia.registerHook('beforeWidgetInitialization', function (allWidgetConfiguration) {
allWidgetConfiguration.configure = allWidgetConfiguration.configure || {};
if (algoliaConfig.ccAnalytics.enabled) {
Expand All @@ -60,6 +66,9 @@ requirejs([

return allWidgetConfiguration;
});

this.hasAddedParameters = true;

},

bindData: function() {
Expand Down Expand Up @@ -256,6 +265,8 @@ requirejs([

};

algoliaInsights.addSearchParameters();

algoliaBundle.$(function ($) {
if (window.algoliaConfig) {
algoliaInsights.track(algoliaConfig);
Expand Down
36 changes: 19 additions & 17 deletions view/frontend/web/internals/algoliaBundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion view/frontend/web/internals/algoliaBundle.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit f905c1f

Please sign in to comment.