Skip to content

Commit aaf7269

Browse files
authored
Merge branch 'release/3.12.1' into update/MAGE-804
2 parents c8fcb0a + 8a747d2 commit aaf7269

File tree

10 files changed

+746
-18
lines changed

10 files changed

+746
-18
lines changed

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/ConfigHelper.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class ConfigHelper
101101
public const NON_CASTABLE_ATTRIBUTES = 'algoliasearch_advanced/advanced/non_castable_attributes';
102102
public const MAX_RECORD_SIZE_LIMIT = 'algoliasearch_advanced/advanced/max_record_size_limit';
103103
public const ANALYTICS_REGION = 'algoliasearch_advanced/advanced/analytics_region';
104+
public const CONNECTION_TIMEOUT = 'algoliasearch_advanced/advanced/connection_timeout';
105+
public const READ_TIMEOUT = 'algoliasearch_advanced/advanced/read_timeout';
106+
public const WRITE_TIMEOUT = 'algoliasearch_advanced/advanced/write_timeout';
104107

105108
public const SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock';
106109

@@ -1175,6 +1178,33 @@ public function getIndexPrefix($storeId = null)
11751178
return $this->configInterface->getValue(self::INDEX_PREFIX, ScopeInterface::SCOPE_STORE, $storeId);
11761179
}
11771180

1181+
/**
1182+
* @param $storeId
1183+
* @return mixed'
1184+
*/
1185+
public function getConnectionTimeout($storeId = null)
1186+
{
1187+
return $this->configInterface->getValue(self::CONNECTION_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1188+
}
1189+
1190+
/**
1191+
* @param $storeId
1192+
* @return mixed'
1193+
*/
1194+
public function getReadTimeout($storeId = null)
1195+
{
1196+
return $this->configInterface->getValue(self::READ_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1197+
}
1198+
1199+
/**
1200+
* @param $storeId
1201+
* @return mixed'
1202+
*/
1203+
public function getWriteTimeout($storeId = null)
1204+
{
1205+
return $this->configInterface->getValue(self::WRITE_TIMEOUT, ScopeInterface::SCOPE_STORE, $storeId);
1206+
}
1207+
11781208
/**
11791209
* @param $storeId
11801210
* @return array|bool|float|int|mixed|string

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+
}

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
/**

etc/adminhtml/system.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,15 @@
12621262
<field id="analytics_region" translate="label comment" type="select" sortOrder="96" showInDefault="1">
12631263
<label>Analytics Region</label>
12641264
<source_model>Algolia\AlgoliaSearch\Model\Source\AnalyticsRegion</source_model>
1265+
</field>
1266+
<field id="connection_timeout" translate="label comment" type="text" sortOrder="100" showInDefault="1">
1267+
<label>Connection Timeout (In Seconds)</label>
1268+
</field>
1269+
<field id="read_timeout" translate="label comment" type="text" sortOrder="105" showInDefault="1">
1270+
<label>Read Timeout (In Seconds)</label>
1271+
</field>
1272+
<field id="write_timeout" translate="label comment" type="text" sortOrder="110" showInDefault="1">
1273+
<label>Write Timeout (In Seconds)</label>
12651274
</field>
12661275
</group>
12671276
<group id="queue" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">

etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
<advanced>
8383
<max_record_size_limit>10000</max_record_size_limit>
8484
<analytics_region>us</analytics_region>
85+
<connection_timeout>2</connection_timeout>
86+
<read_timeout>30</read_timeout>
87+
<write_timeout>30</write_timeout>
8588
</advanced>
8689
<queue>
8790
<number_of_element_by_page>300</number_of_element_by_page>

0 commit comments

Comments
 (0)