Skip to content

Commit 985588b

Browse files
authored
Develop into Master (#1064)
1 parent d7d6ba2 commit 985588b

File tree

12 files changed

+146
-33
lines changed

12 files changed

+146
-33
lines changed

CHANGELOG.md

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

3+
## 2.0.2
4+
5+
### UPDATES
6+
- Update setUserToken to cap character length (#1058)
7+
- Set forwardToReplicas for copy rules to false (#1059)
8+
- Use current store id to get settings for replicas (#1057) @palviggi-flagbit
9+
- Make sure original price range is saved for configurables (#1015) @palviggi-flagbit
10+
11+
### FIXES
12+
- Restore "search as you type" feature (#1061)
13+
- Fix error on URL during Pages indexing (#1012) @palviggi-flagbit
14+
315
## 2.0.1
416

517
### UPDATES

Helper/AlgoliaHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public function copySynonyms($fromIndexName, $toIndexName)
402402
public function copyQueryRules($fromIndexName, $toIndexName)
403403
{
404404
$res = $this->getClient()->copyRules($fromIndexName, $toIndexName, [
405-
'forwardToReplicas' => true,
405+
'forwardToReplicas' => false,
406406
'clearExistingRules' => true,
407407
]);
408408

Helper/Entity/PageHelper.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Cms\Model\Template\FilterProvider;
99
use Magento\Framework\DataObject;
1010
use Magento\Framework\Event\ManagerInterface;
11-
use Magento\Framework\UrlInterface;
11+
use Magento\Framework\UrlFactory;
1212
use Magento\Store\Model\StoreManagerInterface;
1313

1414
class PageHelper
@@ -39,34 +39,34 @@ class PageHelper
3939
private $storeManager;
4040

4141
/**
42-
* @var UrlInterface
42+
* @var UrlFactory
4343
*/
44-
private $frontendUrlBuilder;
44+
private $frontendUrlFactory;
4545

4646
/**
4747
* PageHelper constructor.
4848
*
49-
* @param ManagerInterface $eventManager
49+
* @param ManagerInterface $eventManager
5050
* @param PageCollectionFactory $pageCollectionFactory
51-
* @param ConfigHelper $configHelper
52-
* @param FilterProvider $filterProvider
51+
* @param ConfigHelper $configHelper
52+
* @param FilterProvider $filterProvider
5353
* @param StoreManagerInterface $storeManager
54-
* @param UrlInterface $frontendUrlBuilder
54+
* @param UrlFactory $frontendUrlFactory
5555
*/
5656
public function __construct(
5757
ManagerInterface $eventManager,
5858
PageCollectionFactory $pageCollectionFactory,
5959
ConfigHelper $configHelper,
6060
FilterProvider $filterProvider,
6161
StoreManagerInterface $storeManager,
62-
UrlInterface $frontendUrlBuilder
62+
UrlFactory $frontendUrlFactory
6363
) {
6464
$this->eventManager = $eventManager;
6565
$this->pageCollectionFactory = $pageCollectionFactory;
6666
$this->configHelper = $configHelper;
6767
$this->filterProvider = $filterProvider;
6868
$this->storeManager = $storeManager;
69-
$this->frontendUrlBuilder = $frontendUrlBuilder;
69+
$this->frontendUrlFactory = $frontendUrlFactory;
7070
}
7171

7272
public function getIndexNameSuffix()
@@ -106,6 +106,8 @@ public function getPages($storeId)
106106

107107
$pages = [];
108108

109+
$frontendUrlBuilder = $this->frontendUrlFactory->create()->setScope($storeId);
110+
109111
/** @var Page $page */
110112
foreach ($magentoPages as $page) {
111113
if (in_array($page->getIdentifier(), $excludedPages)) {
@@ -129,14 +131,13 @@ public function getPages($storeId)
129131
}
130132

131133
$pageObject['objectID'] = $page->getId();
132-
$pageObject['url'] = $this->frontendUrlBuilder->setStore($storeId)
133-
->getUrl(
134-
null,
135-
[
136-
'_direct' => $page->getIdentifier(),
137-
'_secure' => $this->configHelper->useSecureUrlsInFrontend($storeId),
138-
]
139-
);
134+
$pageObject['url'] = $frontendUrlBuilder->getUrl(
135+
null,
136+
[
137+
'_direct' => $page->getIdentifier(),
138+
'_secure' => $this->configHelper->useSecureUrlsInFrontend($storeId),
139+
]
140+
);
140141
$pageObject['content'] = $this->strip($content, ['script', 'style']);
141142

142143
$transport = new DataObject($pageObject);

Helper/Entity/Product/PriceManager/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $cu
2323
}
2424
}
2525

26-
return [$min, $max];
26+
return [$min, $max, $min, $max];
2727
}
2828
}

Helper/Entity/Product/PriceManager/ProductWithChildren.php

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ abstract class ProductWithChildren extends ProductWithoutChildren
99
{
1010
protected function addAdditionalData($product, $withTax, $subProducts, $currencyCode, $field)
1111
{
12-
list($min, $max) = $this->getMinMaxPrices($product, $withTax, $subProducts, $currencyCode);
12+
list($min, $max, $minOriginal, $maxOriginal) =
13+
$this->getMinMaxPrices($product, $withTax, $subProducts, $currencyCode);
14+
1315
$dashedFormat = $this->getDashedPriceFormat($min, $max, $currencyCode);
1416

1517
if ($min !== $max) {
1618
$this->handleNonEqualMinMaxPrices($field, $currencyCode, $min, $max, $dashedFormat);
1719
}
1820

21+
$this->handleOriginalPrice($field, $currencyCode, $min, $max, $minOriginal, $maxOriginal);
22+
1923
if (!$this->customData[$field][$currencyCode]['default']) {
2024
$this->handleZeroDefaultPrice($field, $currencyCode, $min, $max);
2125
}
@@ -27,30 +31,38 @@ protected function addAdditionalData($product, $withTax, $subProducts, $currency
2731

2832
protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $currencyCode)
2933
{
30-
$min = PHP_INT_MAX;
31-
$max = 0;
34+
$min = PHP_INT_MAX;
35+
$max = 0;
36+
$original = $min;
37+
$originalMax = $max;
3238

3339
if (count($subProducts) > 0) {
3440
/** @var Product $subProduct */
3541
foreach ($subProducts as $subProduct) {
36-
$price = $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax);
42+
$price = $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax);
43+
$basePrice = $this->getTaxPrice($product, $subProduct->getPrice(), $withTax);
3744

3845
$min = min($min, $price);
46+
$original = min($original, $basePrice);
47+
3948
$max = max($max, $price);
49+
$originalMax = max($max, $basePrice);
4050
}
4151
} else {
42-
$min = $max;
52+
$originalMax = $original = $min = $max;
4353
}
4454

4555
if ($currencyCode !== $this->baseCurrencyCode) {
46-
$min = $this->convertPrice($min, $currencyCode);
56+
$min = $this->convertPrice($min, $currencyCode);
57+
$original = $this->convertPrice($original, $currencyCode);
4758

4859
if ($min !== $max) {
4960
$max = $this->convertPrice($max, $currencyCode);
61+
$originalMax = $this->convertPrice($originalMax, $currencyCode);
5062
}
5163
}
5264

53-
return [$min, $max];
65+
return [$min, $max, $original, $originalMax];
5466
}
5567

5668
protected function getDashedPriceFormat($min, $max, $currencyCode)
@@ -69,7 +81,11 @@ protected function handleNonEqualMinMaxPrices($field, $currencyCode, $min, $max,
6981
$this->customData[$field][$currencyCode]['default_formated'] = $dashedFormat;
7082

7183
//// Do not keep special price that is already taken into account in min max
72-
unset($this->customData['price']['special_from_date'], $this->customData['price']['special_to_date'], $this->customData['price']['default_original_formated']);
84+
unset(
85+
$this->customData['price']['special_from_date'],
86+
$this->customData['price']['special_to_date'],
87+
$this->customData['price']['default_original_formated']
88+
);
7389

7490
$this->customData[$field][$currencyCode]['default'] = 0; // will be reset just after
7591
}
@@ -80,7 +96,7 @@ protected function handleNonEqualMinMaxPrices($field, $currencyCode, $min, $max,
8096
$groupId = (int) $group->getData('customer_group_id');
8197

8298
if ($min !== $max && $min <= $this->customData[$field][$currencyCode]['group_' . $groupId]) {
83-
$this->customData[$field][$currencyCode]['group_' . $groupId] = 0;
99+
$this->customData[$field][$currencyCode]['group_' . $groupId] = 0;
84100
$this->customData[$field][$currencyCode]['group_' . $groupId . '_formated'] = $dashedFormat;
85101
}
86102
}
@@ -95,7 +111,7 @@ protected function handleZeroDefaultPrice($field, $currencyCode, $min, $max)
95111
return;
96112
}
97113

98-
$this->customData[$field][$currencyCode]['default'] = $min;
114+
$this->customData[$field][$currencyCode]['default'] = $min;
99115
$this->customData[$field][$currencyCode]['default_formated'] = $this->formatPrice($min, $currencyCode);
100116
}
101117

@@ -117,4 +133,31 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
117133
}
118134
}
119135
}
136+
137+
public function handleOriginalPrice($field, $currencyCode, $min, $max, $minOriginal, $maxOriginal)
138+
{
139+
if ($min !== $max) {
140+
if ($min !== $minOriginal || $max !== $maxOriginal) {
141+
if ($minOriginal !== $maxOriginal) {
142+
$this->customData[$field][$currencyCode]['default_original_formated'] = $this->getDashedPriceFormat(
143+
$minOriginal,
144+
$maxOriginal,
145+
$currencyCode
146+
);
147+
} else {
148+
$this->customData[$field][$currencyCode]['default_original_formated'] = $this->formatPrice(
149+
$minOriginal,
150+
$currencyCode
151+
);
152+
}
153+
}
154+
} else {
155+
if ($min < $minOriginal) {
156+
$this->customData[$field][$currencyCode]['default_original_formated'] = $this->formatPrice(
157+
$minOriginal,
158+
$currencyCode
159+
);
160+
}
161+
}
162+
}
120163
}

Helper/Entity/ProductHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function setSettings($indexName, $indexNameTmp, $storeId, $saveToTmpIndic
346346

347347
$replicas = [];
348348

349-
if ($this->configHelper->isInstantEnabled() || $this->configHelper->isBackendRenderingEnabled()) {
349+
if ($this->configHelper->isInstantEnabled($storeId) || $this->configHelper->isBackendRenderingEnabled($storeId)) {
350350
$replicas = array_values(array_map(function ($sortingIndex) {
351351
return $sortingIndex['name'];
352352
}, $sortingIndices));

Helper/InsightsHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public function setUserToken(\Magento\Customer\Model\Customer $customer)
150150
{
151151
$userToken = base64_encode('customer-' . $customer->getEmail() . '-' . $customer->getId());
152152
$userToken = 'aa-' . preg_replace('/[^A-Za-z0-9\-]/', '', $userToken);
153+
$userToken = mb_substr($userToken, 0, 64); // character limit
153154

154155
try {
155156
$metaData = $this->cookieMetadataFactory->createPublicCookieMetadata()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Algolia Search for Magento 2
22
==================
33

4-
![Latest version](https://img.shields.io/badge/latest-2.0.1-green.svg)
4+
![Latest version](https://img.shields.io/badge/latest-2.0.2-green.svg)
55
![Magento 2](https://img.shields.io/badge/Magento-%3E=2.2%20<2.4-blue.svg)
66
![PHP >= 7.0.6](https://img.shields.io/badge/PHP-%3E=7.0-green.svg)
77

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Algolia Search integration for Magento 2",
44
"type": "magento2-module",
55
"license": ["MIT"],
6-
"version": "2.0.1",
6+
"version": "2.0.2",
77
"require": {
88
"php": "~7.0|~7.1|~7.2|~7.3",
99
"magento/framework": "~101.0|~102.0",

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Algolia_AlgoliaSearch" setup_version="2.0.1">
3+
<module name="Algolia_AlgoliaSearch" setup_version="2.0.2">
44
<sequence>
55
<module name="Magento_Theme"/>
66
<module name="Magento_Backend"/>

0 commit comments

Comments
 (0)