Skip to content

Commit

Permalink
Merge pull request #1603 from algolia/release/3.14.1
Browse files Browse the repository at this point in the history
Release/3.14.1 - patch release
  • Loading branch information
cammonro authored Aug 30, 2024
2 parents 8214531 + e68d413 commit b29cd68
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 20 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# CHANGE LOG

## 3.14.1

### Updates
- Token clean up on session expiration

### Bug Fixes
- Query string append issue addressed
- Fixed issue with "base table not found" in integration tests due to new CLI command classes
- Removed a warning during indexing of entities with no `created_at` attribute
- Fixed incorrect Recommend paths resulting from earlier JS asset reorg
- README.md updated

## 3.14.0

GA release
Expand Down
2 changes: 1 addition & 1 deletion Console/Command/ReplicaRebuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ReplicaRebuildCommand
use ReplicaDeleteCommandTrait;

public function __construct(
protected ProductHelper $productHelper,
protected ReplicaManagerInterface $replicaManager,
protected ProductHelper $productHelper,
protected StoreManagerInterface $storeManager,
protected ReplicaState $replicaState,
AppState $appState,
Expand Down
3 changes: 1 addition & 2 deletions Console/Command/ReplicaSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ class ReplicaSyncCommand extends AbstractReplicaCommand implements ReplicaSyncCo
use ReplicaSyncCommandTrait;

public function __construct(

protected ProductHelper $productHelper,
protected ReplicaManagerInterface $replicaManager,
protected ProductHelper $productHelper,
protected StoreManagerInterface $storeManager,
State $state,
StoreNameFetcher $storeNameFetcher,
Expand Down
4 changes: 3 additions & 1 deletion Helper/AlgoliaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ protected function prepareRecords(array &$objects, string $indexName): void
foreach ($objects as $key => &$object) {
$object['algoliaLastUpdateAtCET'] = $currentCET;
// Convert created_at to UTC timestamp
$object['created_at'] = strtotime($object['created_at']);
if (isset($object['created_at'])) {
$object['created_at'] = strtotime($object['created_at']);
}

$previousObject = $object;

Expand Down
12 changes: 11 additions & 1 deletion Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ConfigHelper
public const CC_ANALYTICS_IS_SELECTOR = 'algoliasearch_cc_analytics/cc_analytics_group/is_selector';
public const CC_CONVERSION_ANALYTICS_MODE = 'algoliasearch_cc_analytics/cc_analytics_group/conversion_analytics_mode';
public const CC_ADD_TO_CART_SELECTOR = 'algoliasearch_cc_analytics/cc_analytics_group/add_to_cart_selector';
public const COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';

public const GA_ENABLE = 'algoliasearch_analytics/analytics_group/enable';
public const GA_DELAY = 'algoliasearch_analytics/analytics_group/delay';
Expand Down Expand Up @@ -142,7 +143,7 @@ class ConfigHelper
protected const IS_LOOKING_SIMILAR_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_pdp';
protected const IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_cart_page';
protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
public const LEGACY_USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
public const LEGACY_USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
protected const AUTOCOMPLETE_KEYBORAD_NAVIAGATION = 'algoliasearch_autocomplete/autocomplete/navigator';
protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
protected const RELATED_PRODUCTS_TITLE = 'algoliasearch_recommend/recommend/related_product/title';
Expand Down Expand Up @@ -1872,4 +1873,13 @@ public function isCookieRestrictionModeEnabled()
{
return (bool)$this->cookieHelper->isCookieRestrictionModeEnabled();
}

/**
* @param $storeId
* @return mixed
*/
public function getCookieLifetime($storeId = null)
{
return $this->configInterface->getValue(self::COOKIE_LIFETIME, ScopeInterface::SCOPE_STORE, $storeId);
}
}
2 changes: 1 addition & 1 deletion Helper/InsightsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function setAuthenticatedUserToken(Customer $customer): string|null
$userToken = $this->generateAuthenticatedUserToken($customer);

$metaData = $this->cookieMetadataFactory->createPublicCookieMetadata()
->setDurationOneYear()
->setDuration($this->configHelper->getCookieLifetime())
->setPath('/')
->setHttpOnly(false)
->setSecure(false);
Expand Down
37 changes: 37 additions & 0 deletions Observer/Insights/CookieRefresherObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Algolia\AlgoliaSearch\Observer\Insights;

use Algolia\AlgoliaSearch\Helper\InsightsHelper;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class CookieRefresherObserver implements ObserverInterface
{
/**
* CookieRefresherObserver observer constructor.
*
* @param CustomerSession $customerSession
* @param InsightsHelper $insightsHelper
*
*/
public function __construct(
private readonly CustomerSession $customerSession,
private readonly InsightsHelper $insightsHelper,
) {}

/**
* Renew anonymous or customer session token to update the lifetime
*
* @param Observer $observer
*
* @return void
*/
public function execute(Observer $observer): void
{
if ($this->customerSession->isLoggedIn()) {
$this->insightsHelper->setAuthenticatedUserToken($this->customerSession->getCustomer());
}
}
}
1 change: 1 addition & 0 deletions Observer/Insights/CustomerLogout.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function execute(\Magento\Framework\Event\Observer $observer): void
try {
$this->cookieManager->setPublicCookie(self::UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME, 1, $metaDataUnset);
$this->cookieManager->deleteCookie(InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME, $metadata);
$this->cookieManager->deleteCookie(InsightsHelper::ALGOLIA_ANON_USER_TOKEN_COOKIE_NAME, $metadata);
} catch (LocalizedException $e) {
$this->logger->error("Error writing Algolia customer cookies: " . $e->getMessage());
}
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Algolia Search & Discovery extension for Magento 2
==================================================

![Latest version](https://img.shields.io/badge/latest-3.14.0-green)
![Latest version](https://img.shields.io/badge/latest-3.14.1-green)
![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange)

![PHP](https://img.shields.io/badge/PHP-8.1%2C8.2%2C8.3-blue)
Expand Down Expand Up @@ -35,10 +35,16 @@ Magento 2.3 and earlier versions are no longer supported by the Algolia extensio

Version 3.x of our extension is compatible with Magento 2.4. Review the [Customisation](https://github.com/algolia/algoliasearch-magento-2#customisation) section to learn more about the differences between our extension versions.

| Extension Version | End of Life | Magento | PHP |
|-------------------| --- |----------| ---------|
| v3.13.x | N/A | `2.4.x` | `^7.2 \|\| ^8.0` |
| v3.14.x | N/A | `2.4.x` | `>=8.1` |
| Extension Version | End of Life | Magento | PHP |
|-------------------|-------------|------------------------------|----------------------------------------|
| v3.7.x | 10/10/2023 | `~2.3.7\|\|~2.4.5\|\|~2.4.6` | `~7.3.0\|\|~7.4.0\|\|~8.1.0\|\|~8.2.0` |
| v3.8.x | 3/8/2023 | `~2.4.5\|\|~2.4.6` | `~7.4.0\|\|~8.1.0\|\|~8.2.0` |
| v3.9.x | 10/13/2023 | `~2.4.5\|\|~2.4.6` | `~7.4.0\|\|~8.1.0\|\|~8.2.0` |
| v3.10.x | 12/12/2023 | `~2.4.6` | `~8.1.0\|\|~8.2.0` |
| v3.11.x | 1/26/2024 | `~2.4.6` | `~8.1.0\|\|~8.2.0` |
| v3.12.x | 8/2/2024 | `~2.4.6` | `~8.1.0\|\|~8.2.0` |
| v3.13.x | N/A | `~2.4.6` | `~8.1.0\|\|~8.2.0` |
| v3.14.x | N/A | `~2.4.6\|\|~2.4.7` | `~8.1.0\|\|~8.2.0\|\|~8.3.0` |

## Documentation

Expand All @@ -56,7 +62,7 @@ The easiest way to install the extension is to use [Composer](https://getcompose

If you would like to stay on a minor version, please upgrade your composer to only accept minor versions. The following example will keep you on the minor version and will update patches automatically.

`"algolia/algoliasearch-magento-2": "~3.14.0"`
`"algolia/algoliasearch-magento-2": "~3.14.1"`

### Customisation

Expand All @@ -77,8 +83,11 @@ Knowing the version of the library will help you understand what is available in
| v3.11.0 | [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) | [2.6.0](https://github.com/algolia/search-insights.js/tree/v2.6.0) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) |
| v3.13.0 | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.63.0](https://github.com/algolia/instantsearch/tree/instantsearch.js%404.63.0) | [2.6.0](https://github.com/algolia/search-insights.js/tree/v2.6.0) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) |
| >=v3.14.x | [1.6.3](https://github.com/algolia/autocomplete.js/tree/v1.6.3) | [4.63.0](https://github.com/algolia/instantsearch/tree/instantsearch.js%404.63.0) | [2.6.0](https://github.com/algolia/search-insights.js/tree/v2.6.0) | [1.15.0](https://github.com/algolia/recommend/tree/v1.15.0) |

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:

v3.x latest bundle: https://github.com/algolia/algoliasearch-extensions-bundle/blob/ISv4/package.json

The search-insights.js library is standalone.

Refer to these docs when customising your Algolia Magento extension frontend features:
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 & Discovery extension for Magento 2",
"type": "magento2-module",
"license": ["MIT"],
"version": "3.14.0",
"version": "3.14.1",
"require": {
"php": "~8.1|~8.2|~8.3",
"magento/framework": "~103.0",
Expand Down
29 changes: 29 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,33 @@
</argument>
</arguments>
</type>

<type name="Algolia\AlgoliaSearch\Console\Command\ReplicaSyncCommand">
<arguments>
<argument name="replicaManager" xsi:type="object">Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface\Proxy</argument>
<argument name="productHelper" xsi:type="object">Algolia\AlgoliaSearch\Helper\Entity\ProductHelper\Proxy</argument>
</arguments>
</type>

<type name="Algolia\AlgoliaSearch\Console\Command\ReplicaDeleteCommand">
<arguments>
<argument name="replicaManager" xsi:type="object">Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface\Proxy</argument>
</arguments>
</type>

<type name="Algolia\AlgoliaSearch\Console\Command\ReplicaRebuildCommand">
<arguments>
<argument name="replicaManager" xsi:type="object">Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface\Proxy</argument>
<argument name="productHelper" xsi:type="object">Algolia\AlgoliaSearch\Helper\Entity\ProductHelper\Proxy</argument>
</arguments>
</type>

<type name="Algolia\AlgoliaSearch\Console\Command\ReplicaDisableVirtualCommand">
<arguments>
<argument name="configHelper" xsi:type="object">Algolia\AlgoliaSearch\Helper\ConfigHelper\Proxy</argument>
<argument name="replicaManager" xsi:type="object">Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface\Proxy</argument>
<argument name="productHelper" xsi:type="object">Algolia\AlgoliaSearch\Helper\Entity\ProductHelper\Proxy</argument>
</arguments>
</type>

</config>
3 changes: 3 additions & 0 deletions etc/frontend/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@
<event name="catalog_controller_product_init_after">
<observer name="algoliasearch_current_product" instance="Algolia\AlgoliaSearch\Observer\RegisterCurrentProductObserver"/>
</event>
<event name="controller_action_predispatch">
<observer name="algoliasearch_cookie_refresher" instance="Algolia\AlgoliaSearch\Observer\Insights\CookieRefresherObserver" shared="false" />
</event>
</config>
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.14.0">
<module name="Algolia_AlgoliaSearch" setup_version="3.14.1">
<sequence>
<module name="Magento_Theme"/>
<module name="Magento_Backend"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (!empty($recommendConfig['enabledRelatedInCart']) || !empty($recommendConfig[
<script type="text/x-magento-init">
{
"*": {
"Algolia_AlgoliaSearch/recommend" : {
"Algolia_AlgoliaSearch/js/recommend" : {
"objectIDs" : <?= json_encode($cartItems) ?>
}
}
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/recommend/products.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!empty($recommendConfig['enabledFBT'])
<script type="text/x-magento-init">
{
"*": {
"Algolia_AlgoliaSearch/recommend" : {
"Algolia_AlgoliaSearch/js/recommend" : {
"objectIDs" : ["<?= $product->getId() ?>"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if ($isEnabled):
<script type="text/x-magento-init">
{
"*": {
"Algolia_AlgoliaSearch/recommend" : {
"Algolia_AlgoliaSearch/js/recommend" : {
"recommendLSContainer" : "<?= $lsContainer ?>",
"numOfLookingSimilarItem" : "<?= $block->getData('numOfLookingSimilarItem') ?>",
"objectIDs" : <?= $block->getProductIds() ?>
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/templates/recommend/widget/trends-item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if ($isEnabled):
<script type="text/x-magento-init">
{
"*": {
"Algolia_AlgoliaSearch/recommend" : {
"Algolia_AlgoliaSearch/js/recommend" : {
"recommendTrendContainer" : "<?= $trendConstainer ?>",
"numOfTrendsItem" : "<?= $block->getData('numOfTrendsItem') ?>",
"facetName" : "<?= $block->getData('facetName') ?>",
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ define([
indexName: hit.__autocomplete_indexName,
});
if (hit.url.indexOf('?') > -1) {
hit.urlForInsights += insightsDataUrlString;
hit.urlForInsights += '&' + insightsDataUrlString;
} else {
hit.urlForInsights += '?' + insightsDataUrlString;
}
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/internals/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
indexName: hit.__indexName
});
if (hit.url.indexOf('?') > -1) {
hit.urlForInsights += insightsDataUrlString
hit.urlForInsights += '&' + insightsDataUrlString;
} else {
hit.urlForInsights += '?' + insightsDataUrlString;
}
Expand Down

0 comments on commit b29cd68

Please sign in to comment.