Skip to content

Commit 60e3f85

Browse files
authored
Merge branch 'develop' into bugfix/MAGE-561
2 parents 55b7d1f + f0010a3 commit 60e3f85

File tree

17 files changed

+856
-72
lines changed

17 files changed

+856
-72
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# CHANGE LOG
22

3+
## 3.13.0
4+
5+
### Updates
6+
- Updated instantSearch library version from 4.41.0 to 4.63.0
7+
- Updated disclaimer for advanced algolia indices settings in the magento admin
8+
9+
## 3.12.1
10+
11+
### Updates
12+
- Updated insights library version from 2.6.0 to 2.11.0
13+
- Updated all click events to add authenticatedUserToken for login customer
14+
- Updated view events to add authenticatedUserToken for login customer
15+
- Added German translations in plugin
16+
- Updated code to provide a way for customers to modify timeout values for Algolia PHP Client
17+
18+
### Bug Fixes
19+
- Fixed the issue with recommendations for grouped products in cart page
20+
- Fixed the issue with InstantSearch filters with quotations
21+
322
## 3.12.0
423

524
### Updates

Helper/AlgoliaHelper.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Algolia\AlgoliaSearch\Response\AbstractResponse;
77
use Algolia\AlgoliaSearch\Response\BatchIndexingResponse;
88
use Algolia\AlgoliaSearch\Response\MultiResponse;
9+
use Algolia\AlgoliaSearch\Config\SearchConfig;
910
use Algolia\AlgoliaSearch\SearchClient;
1011
use Algolia\AlgoliaSearch\SearchIndex;
1112
use Algolia\AlgoliaSearch\Support\UserAgent;
@@ -89,10 +90,11 @@ public function getRequest()
8990
public function resetCredentialsFromConfig()
9091
{
9192
if ($this->config->getApplicationID() && $this->config->getAPIKey()) {
92-
$this->client = SearchClient::create(
93-
$this->config->getApplicationID(),
94-
$this->config->getAPIKey()
95-
);
93+
$config = SearchConfig::create($this->config->getApplicationID(), $this->config->getAPIKey());
94+
$config->setConnectTimeout($this->config->getConnectionTimeout());
95+
$config->setReadTimeout($this->config->getReadTimeout());
96+
$config->setWriteTimeout($this->config->getWriteTimeout());
97+
$this->client = SearchClient::createWithConfig($config);
9698
}
9799
}
98100

Helper/AnalyticsHelper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class AnalyticsHelper
5151
private $analyticsConfig;
5252

5353
/**
54-
* Can be changed through DI
54+
* Region can be modified via the Magento configuration
5555
*
5656
* @var string
5757
*/
58-
private $region;
58+
protected $region;
5959

6060
/**
6161
* @param AlgoliaHelper $algoliaHelper
@@ -77,7 +77,7 @@ public function __construct(
7777
$this->entityHelper = $entityHelper;
7878

7979
$this->logger = $logger;
80-
$this->region = $region;
80+
$this->region = $this->configHelper->getAnalyticsRegion();
8181
}
8282

8383
private function setupAnalyticsClient()
@@ -86,6 +86,7 @@ private function setupAnalyticsClient()
8686
return;
8787
}
8888

89+
8990
$this->analyticsClient = AnalyticsClient::create(
9091
$this->configHelper->getApplicationID(),
9192
$this->configHelper->getAPIKey(),

Helper/ConfigHelper.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class ConfigHelper
102102
'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents';
103103
public const NON_CASTABLE_ATTRIBUTES = 'algoliasearch_advanced/advanced/non_castable_attributes';
104104
public const MAX_RECORD_SIZE_LIMIT = 'algoliasearch_advanced/advanced/max_record_size_limit';
105+
public const ANALYTICS_REGION = 'algoliasearch_advanced/advanced/analytics_region';
106+
public const CONNECTION_TIMEOUT = 'algoliasearch_advanced/advanced/connection_timeout';
107+
public const READ_TIMEOUT = 'algoliasearch_advanced/advanced/read_timeout';
108+
public const WRITE_TIMEOUT = 'algoliasearch_advanced/advanced/write_timeout';
105109

106110
public const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
107111

@@ -1190,6 +1194,33 @@ public function getIndexPrefix($storeId = null)
11901194
return $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId);
11911195
}
11921196

1197+
/**
1198+
* @param $storeId
1199+
* @return mixed'
1200+
*/
1201+
public function getConnectionTimeout($storeId = null)
1202+
{
1203+
return $this->configInterface->getValue(self::CONNECTION_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1204+
}
1205+
1206+
/**
1207+
* @param $storeId
1208+
* @return mixed'
1209+
*/
1210+
public function getReadTimeout($storeId = null)
1211+
{
1212+
return $this->configInterface->getValue(self::READ_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1213+
}
1214+
1215+
/**
1216+
* @param $storeId
1217+
* @return mixed'
1218+
*/
1219+
public function getWriteTimeout($storeId = null)
1220+
{
1221+
return $this->configInterface->getValue(self::WRITE_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1222+
}
1223+
11931224
/**
11941225
* @param $storeId
11951226
* @return array|bool|float|int|mixed|string
@@ -1701,6 +1732,19 @@ public function getMaxRecordSizeLimit($storeId = null)
17011732
);
17021733
}
17031734

1735+
/**
1736+
* @param $storeId
1737+
* @return string
1738+
*/
1739+
public function getAnalyticsRegion($storeId = null)
1740+
{
1741+
return $this->configInterface->getValue(
1742+
self::ANALYTICS_REGION,
1743+
ScopeInterface::SCOPE_STORE,
1744+
$storeId
1745+
);
1746+
}
1747+
17041748
/**
17051749
* @param $storeId
17061750
* @return bool

Model/Source/AnalyticsRegion.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Model\Source;
4+
5+
use Magento\Framework\Option\ArrayInterface;
6+
7+
class AnalyticsRegion implements ArrayInterface
8+
{
9+
public function toOptionArray()
10+
{
11+
return [
12+
['value' => 'us', 'label' => __('United States')],
13+
['value' => 'de', 'label' => __('Europe (Germany)')],
14+
];
15+
}
16+
}

Observer/Insights/CustomerLogout.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
class CustomerLogout implements ObserverInterface
1111
{
12+
public const UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME = "unset_authentication_token";
1213
/**
1314
* @var PhpCookieManager
1415
*/
@@ -42,9 +43,15 @@ public function __construct(
4243
public function execute(\Magento\Framework\Event\Observer $observer)
4344
{
4445
if ($this->cookieManager->getCookie(InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME)) {
46+
$metaDataUnset = $this->cookieMetadataFactory->createPublicCookieMetadata()
47+
->setDurationOneYear()
48+
->setPath('/')
49+
->setHttpOnly(false)
50+
->setSecure(false);
51+
$this->cookieManager->setPublicCookie(self::UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME, 1, $metaDataUnset);
4552
$metadata = $this->cookieMetadataFactory->createCookieMetadata();
4653
$metadata->setPath('/');
4754
$this->cookieManager->deleteCookie(InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME, $metadata);
4855
}
4956
}
50-
}
57+
}

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Algolia Search & Discovery extension for Magento 2
22
==================================================
33

4-
![Latest version](https://img.shields.io/badge/latest-3.12.0-green)
4+
![Latest version](https://img.shields.io/badge/latest-3.13.0-green)
55
![Magento 2](https://img.shields.io/badge/Magento-2.4.x-orange)
66

77
![PHP](https://img.shields.io/badge/PHP-8.2%2C8.1%2C7.4-blue)
@@ -74,14 +74,16 @@ Please check our [Custom Extension](https://github.com/algolia/algoliasearch-cus
7474

7575
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.
7676

77-
| Extension Version | autocomplete.js | instantsearch.js | search-insights.js | recommend.js |
78-
|-------------------|-------------------------------------------------------------------| --- | --- | --- |
79-
| 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]) | NA |
80-
| 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) | NA |
81-
| 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) | NA |
82-
| v3.9.1 | [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) | [1.5.0](https://github.com/algolia/recommend/tree/v1.5.0) |
83-
| v3.10.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) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) |
84-
| >=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) |
77+
| Extension Version | autocomplete.js | instantsearch.js | search-insights.js | recommend.js |
78+
|-----------------|-------------------------------------------------------------------|--------------------------------------------------------------------| --- | --- |
79+
| 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]) | NA |
80+
| 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) | NA |
81+
| 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) | NA |
82+
| v3.9.1 | [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) | [1.5.0](https://github.com/algolia/recommend/tree/v1.5.0) |
83+
| v3.10.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) | [1.8.0](https://github.com/algolia/recommend/tree/v1.8.0) |
84+
| 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) |
85+
| >=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) |
86+
8587

8688
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:
8789

ViewModel/Recommend/Cart.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Algolia\AlgoliaSearch\ViewModel\Recommend;
44

55
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
6+
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
67
use Magento\Checkout\Model\Session;
8+
use Magento\Framework\Exception\LocalizedException;
9+
use Magento\Framework\Exception\NoSuchEntityException;
710
use Magento\Framework\View\Element\Block\ArgumentInterface;
8-
use Magento\Framework\View\Element\Template\Context;
11+
use Magento\Store\Model\StoreManagerInterface;
912

1013
class Cart implements ArgumentInterface
1114
{
@@ -20,34 +23,49 @@ class Cart implements ArgumentInterface
2023
protected $configHelper;
2124

2225
/**
23-
* @param Context $context
26+
* @var ProductHelper
27+
*/
28+
protected $productHelper;
29+
30+
/**
31+
* @param StoreManagerInterface $storeManager
2432
* @param Session $checkoutSession
2533
* @param ConfigHelper $configHelper
26-
* @param array $data
34+
* @param ProductHelper $productHelper
2735
*/
2836
public function __construct(
29-
Context $context,
37+
StoreManagerInterface $storeManager,
3038
Session $checkoutSession,
3139
ConfigHelper $configHelper,
32-
array $data = []
40+
ProductHelper $productHelper
3341
) {
42+
$this->storeManager = $storeManager;
3443
$this->checkoutSession = $checkoutSession;
3544
$this->configHelper = $configHelper;
45+
$this->productHelper = $productHelper;
3646
}
3747

3848
/**
3949
* @return array
40-
* @throws \Magento\Framework\Exception\LocalizedException
41-
* @throws \Magento\Framework\Exception\NoSuchEntityException
50+
* @throws LocalizedException
51+
* @throws NoSuchEntityException
4252
*/
4353
public function getAllCartItems()
4454
{
4555
$cartItems = [];
56+
$visibleCartItem = [];
4657
$itemCollection = $this->checkoutSession->getQuote()->getAllVisibleItems();
4758
foreach ($itemCollection as $item) {
4859
$cartItems[] = $item->getProductId();
4960
}
50-
return array_unique($cartItems);
61+
$storeId = $this->storeManager->getStore()->getId();
62+
$cartProductCollection = $this->productHelper->getProductCollectionQuery($storeId, array_unique($cartItems));
63+
if ($cartProductCollection->getSize() > 0 ){
64+
foreach ($cartProductCollection as $product) {
65+
$visibleCartItem[] = $product->getId();
66+
}
67+
}
68+
return $visibleCartItem;
5169
}
5270

5371
/**

composer.json

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Algolia Search & Discovery extension for Magento 2",
44
"type": "magento2-module",
55
"license": ["MIT"],
6-
"version": "3.12.0",
6+
"version": "3.13.0",
77
"require": {
88
"magento/framework": "~102.0|~103.0",
99
"algolia/algoliasearch-client-php": "3.3.2",

0 commit comments

Comments
 (0)