Skip to content

Commit

Permalink
Merge pull request #1225 from algolia/develop
Browse files Browse the repository at this point in the history
Release 3.8.0
  • Loading branch information
ratikant-singh authored Aug 2, 2022
2 parents d333c95 + 776aaca commit 37295d7
Show file tree
Hide file tree
Showing 32 changed files with 1,825 additions and 1,068 deletions.
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ jobs:
key: composer-v4-{{ checksum "composer.json" }}
paths:
- vendor
- run:
name: Quality tools
command: |
sudo ~/.composer/vendor/bin/magento2-test ~/magento_directory/vendor/algolia/algoliasearch-magento-2 ~/.composer/vendor/bin/

workflows:
version: 2
Expand Down
14 changes: 14 additions & 0 deletions Block/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function getConfiguration()
$customerGroupId = $this->getGroupId();

$priceKey = $this->getPriceKey();
$priceGroup = null;
if ($config->isCustomerGroupsEnabled()) {
$pricegroupArray = explode('.', $priceKey);
$priceGroup = $pricegroupArray[2];
}

$query = '';
$refinementKey = '';
Expand Down Expand Up @@ -157,6 +162,12 @@ public function getConfiguration()
'query' => $this->getLandingPageQuery(),
'configuration' => $this->getLandingPageConfiguration(),
],
'recommend' => [
'enabledFBT' => $config->isRecommendFrequentlyBroughtTogetherEnabled(),
'enabledRelated' => $config->isRecommendRelatedProductsEnabled(),
'limitFBTProducts' => $config->getNumberOfFrequentlyBoughtTogetherProducts(),
'limitRelatedProducts' => $config->getNumberOfRelatedProducts(),
],
'extensionVersion' => $config->getExtensionVersion(),
'applicationId' => $config->getApplicationID(),
'indexName' => $coreHelper->getBaseIndexName(),
Expand All @@ -182,6 +193,9 @@ public function getConfiguration()
'removeBranding' => (bool) $config->isRemoveBranding(),
'productId' => $productId,
'priceKey' => $priceKey,
'priceGroup' => $priceGroup,
'origFormatedVar' => 'price' . $priceKey . '_original_formated',
'tierFormatedVar' => 'price' . $priceKey . '_tier_formated',
'currencyCode' => $currencyCode,
'currencySymbol' => $currencySymbol,
'priceFormat' => $priceFormat,
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# CHANGE LOG

## 3.8.0

### New Features
- Added Algolia Recommend(#1212)

### UPDATES
- Updated Autocomplete V1.6.3 (#1217)

### FIXES
- Fixed the analytics dashboard issue in the magento admin(#1215)
- Fixed the compatibility issue with landing page (#1216)
- Fixed the issue with in_numeric in search suggestion indexing(#1218)

## 3.7.0

### UPDATES
Expand Down
2 changes: 0 additions & 2 deletions DataProvider/Analytics/IndexEntityDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public function getCategoryCollection($storeId, $objectIds)

$collection
->setStoreId($storeId)
->addStoreFilter($storeId)
->addAttributeToSelect('name')
->addAttributeToFilter('entity_id', ['in' => $objectIds]);

Expand All @@ -135,7 +134,6 @@ public function getPageCollection($storeId, $objectIds)
$collection = $this->pageCollection->create();

$collection
->setStoreId($storeId)
->addStoreFilter($storeId)
->addFieldToSelect(['page_id', 'title', 'identifier'])
->addFieldToFilter('page_id', ['in' => $objectIds]);
Expand Down
2 changes: 1 addition & 1 deletion Helper/AlgoliaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AlgoliaHelper extends AbstractHelper
private $potentiallyLongAttributes = ['description', 'short_description', 'meta_description', 'content'];

/** @var array */
private $nonCastableAttributes = ['sku', 'name', 'description'];
private $nonCastableAttributes = ['sku', 'name', 'description', 'query'];

/** @var string */
private static $lastUsedIndexName;
Expand Down
75 changes: 75 additions & 0 deletions Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ class ConfigHelper

public const DEFAULT_MAX_RECORD_SIZE = 10000;

public const IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED = 'algoliasearch_recommend/recommend/is_frequently_bought_together_enabled';
public const IS_RECOMMEND_RELATED_PRODUCTS_ENABLED = 'algoliasearch_recommend/recommend/is_related_products_enabled';
public const NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS = 'algoliasearch_recommend/recommend/num_of_frequently_bought_together_products';
public const NUM_OF_RECOMMEND_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/num_of_related_products';
public const IS_REMOVE_RELATED_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/is_remove_core_related_products_block';
public const IS_REMOVE_UPSELL_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/is_remove_core_upsell_products_block';

private $configInterface;
private $objectManager;
private $currency;
Expand Down Expand Up @@ -425,6 +432,74 @@ public function isInstantEnabled($storeId = null)
return $this->configInterface->isSetFlag(self::IS_INSTANT_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}

/**
* @param int $storeId
*
* @return int
*/
public function isRecommendFrequentlyBroughtTogetherEnabled($storeId = null)
{
return $this->configInterface->isSetFlag(self::IS_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}

/**
* @param int $storeId
*
* @return int
*/
public function isRecommendRelatedProductsEnabled($storeId = null)
{
return $this->configInterface->isSetFlag(self::IS_RECOMMEND_RELATED_PRODUCTS_ENABLED, ScopeInterface::SCOPE_STORE, $storeId);
}

/**
* @param int $storeId
*
* @return int
*/
public function isRemoveCoreRelatedProductsBlock($storeId = null)
{
return $this->configInterface->isSetFlag(self::IS_REMOVE_RELATED_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
}

/**
* @param int $storeId
*
* @return int
*/
public function isRemoveUpsellProductsBlock($storeId = null)
{
return $this->configInterface->isSetFlag(self::IS_REMOVE_UPSELL_PRODUCTS_BLOCK, ScopeInterface::SCOPE_STORE, $storeId);
}

/**
* @param int $storeId
*
* @return int
*/
public function getNumberOfRelatedProducts($storeId = null)
{
return (int) $this->configInterface->getValue(
self::NUM_OF_RECOMMEND_RELATED_PRODUCTS,
ScopeInterface::SCOPE_STORE,
$storeId
);
}

/**
* @param int $storeId
*
* @return int
*/
public function getNumberOfFrequentlyBoughtTogetherProducts($storeId = null)
{
return (int) $this->configInterface->getValue(
self::NUM_OF_RECOMMEND_FREQUENTLY_BOUGHT_TOGETHER_PRODUCTS,
ScopeInterface::SCOPE_STORE,
$storeId
);
}

public function useAdaptiveImage($storeId = null)
{
return $this->configInterface->isSetFlag(self::USE_ADAPTIVE_IMAGE, ScopeInterface::SCOPE_STORE, $storeId);
Expand Down
17 changes: 17 additions & 0 deletions Helper/Configuration/AssetHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class AssetHelper extends \Magento\Framework\App\Helper\AbstractHelper
'url' => 'https://www.youtube.com/watch?v=45NKJbrs1Z4',
'thumbnail' => 'https://img.youtube.com/vi/45NKJbrs1Z4/mqdefault.jpg',
],
'algoliasearch_recommend' => [
'title' => 'Algolia eCommerce Recommendations',
'url' => 'https://www.youtube.com/watch?v=CmoNHmOMedQ',
'thumbnail' => 'https://img.youtube.com/vi/CmoNHmOMedQ/mqdefault.jpg',
],
];

/** @var array */
Expand Down Expand Up @@ -166,6 +171,18 @@ class AssetHelper extends \Magento\Framework\App\Helper\AbstractHelper
'icon' => 'iconDocs',
],
],
'algoliasearch_recommend' => [
[
'title' => 'Algolia Recommend',
'url' => 'https://www.algolia.com/doc/guides/algolia-recommend/overview/',
'icon' => 'iconDocs',
],
[
'title' => 'Setup Recommend',
'url' => 'https://www.algolia.com/doc/guides/algolia-recommend/how-to/set-up/',
'icon' => 'iconDocs',
],
],
];

private $icons = [];
Expand Down
39 changes: 39 additions & 0 deletions Plugin/RemovePdpProductsBlock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Algolia\AlgoliaSearch\Plugin;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Magento\Framework\View\Element\AbstractBlock;

class RemovePdpProductsBlock
{
const RELATED_BLOCK_NAME = 'catalog.product.related';
const UPSELL_BLOCK_NAME = 'product.info.upsell';
/**
* @var ConfigHelper
*/
private $_configHelper;

/**
* @param ConfigHelper $configHelper
*/
public function __construct(ConfigHelper $configHelper)
{
$this->_configHelper = $configHelper;
}

/**
* @param AbstractBlock $subject
* @param $result
*
* @return mixed|string
*/
public function afterToHtml(AbstractBlock $subject, $result)
{
if (($subject->getNameInLayout() === self::RELATED_BLOCK_NAME && $this->_configHelper->isRemoveCoreRelatedProductsBlock()) || ($subject->getNameInLayout() === self::UPSELL_BLOCK_NAME && $this->_configHelper->isRemoveUpsellProductsBlock())) {
return '';
}

return $result;
}
}
16 changes: 9 additions & 7 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.7.0-green)
![Latest version](https://img.shields.io/badge/latest-3.8.0-green)
![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange)

![PHP](https://img.shields.io/badge/PHP-7.4%2C8.1-blue)
Expand Down Expand Up @@ -32,6 +32,8 @@ Additionally, we are announcing the end of life for our legacy versions. We will

- **Instantsearch results page:** Have your search results page, navigation and pagination updated in realtime, after each keystroke.

- **Recommend:** Algolia Recommend lets you display recommendations such as "Frequently Bought Together" and "Related Products" features on the product detail page.

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).*
Expand Down Expand Up @@ -87,12 +89,12 @@ These libraries are here to help add to your customisation but because the exten
#### The Extension JS Bundle
Knowing the version of the library will help you understand what is available in these libraries for you to leverage in terms of customisation. This table will help you determine which documentation to reference when you start working on your customisation.

| Extension Version | autocomplete.js | instantsearch.js | search-insights.js |
| --- | --- | --- | --- |
| 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.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) |
| v3.7.x | [0.38.0](https://github.com/algolia/autocomplete.js/tree/v0.38.0) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.0) | [1.7.1](https://github.com/algolia/search-insights.js/tree/v1.7.1) |
| Extension Version | autocomplete.js | instantsearch.js | search-insights.js |
|-------------------|-------------------------------------------------------------------| --- | --- |
| 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.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) |
| v3.8.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.41.0](https://github.com/algolia/instantsearch.js/tree/v4.41.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
6 changes: 1 addition & 5 deletions ViewModel/Adminhtml/Analytics/Overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Overview implements \Magento\Framework\View\Element\Block\ArgumentInterfac

public const DEFAULT_TYPE = 'products';

public const DEFAULT_RETENTION_DAYS = 7;
public const DEFAULT_RETENTION_DAYS = 90;

/** @var BackendView */
private $backendView;
Expand Down Expand Up @@ -330,10 +330,6 @@ public function checkIsValidDateRange()
public function getAnalyticRetentionDays()
{
$retention = self::DEFAULT_RETENTION_DAYS;
$clientData = $this->analyticsHelper->getClientData();
if (isset($clientData['analytics_retention_days'])) {
$retention = (int) $clientData['analytics_retention_days'];
}

return $retention;
}
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.7.0",
"version": "3.8.0",
"require": {
"magento/framework": "~102.0|~103.0",
"algolia/algoliasearch-client-php": "^3.2",
Expand Down
76 changes: 76 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,82 @@
</field>
</group>
</section>
<section id="algoliasearch_recommend" translate="label" type="text" sortOrder="45" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Recommend Products Settings</label>
<tab>algolia</tab>
<resource>Algolia_AlgoliaSearch::algolia_algoliasearch</resource>
<group id="recommend" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Algolia Recommend Products Settings</label>
<comment>
<![CDATA[
<div class="algolia-admin-content"></div>
]]>
</comment>
<field id="is_frequently_bought_together_enabled" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Frequently Bought Together</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
<![CDATA[
Do you want the frequently bought together products to display inside a product detail page after main product info?
<br><span class="algolia-config-warning">&#9888;</span> Enabling frequently bought together products can potentially break your design on PDP page and some work will be required to have a good integration with your theme.
]]>
</comment>
</field>
<field id="num_of_frequently_bought_together_products" translate="label comment" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<validate>validate-digits</validate>
<label>Number of Frequently Bought Together Products</label>
<comment>
<![CDATA[
How many products do you want to display in the Frequently Bought Together? Default value is 6.
]]>
</comment>
<depends>
<field id="is_frequently_bought_together_enabled">1</field>
</depends>
</field>
<field id="is_related_products_enabled" translate="label comment" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Related Products</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
<![CDATA[
Do you want the related products to display inside a product detail page after main product info?
<br><span class="algolia-config-warning">&#9888;</span> Enabling related products can potentially break your design on PDP page and some work will be required to have a good integration with your theme.
]]>
</comment>
</field>

<field id="num_of_related_products" translate="label comment" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<validate>validate-digits</validate>
<label>Number of Related Products</label>
<comment>
<![CDATA[
How many products do you want to display in the related products? Default value is 6.
]]>
</comment>
<depends>
<field id="is_related_products_enabled">1</field>
</depends>
</field>
<field id="is_remove_core_related_products_block" translate="label comment" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Remove The Magento Related Products Block</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
<![CDATA[
Do you want to remove the magento default related products inside a product detail page?
]]>
</comment>
</field>
<field id="is_remove_core_upsell_products_block" translate="label comment" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Remove The Magento Upsell Products Block</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
<![CDATA[
Do you want to remove the magento default upsell products inside a product detail page?
]]>
</comment>
</field>
</group>
</section>
<section id="algoliasearch_images" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Images</label>
<tab>algolia</tab>
Expand Down
Loading

1 comment on commit 37295d7

@SerhiyDmytruk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if the template is in the autocomplete/product.phtml is now appearing, but not common.js!

After updating M2 from 2.4.4 to 2.4.5 only common,js templates are available.

Please sign in to comment.