Skip to content

Commit eedca31

Browse files
authored
Merge pull request #1379 from algolia/release/3.10.5
Release/3.10.5
2 parents 84069b4 + 54841f5 commit eedca31

18 files changed

+154
-21
lines changed

Block/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public function getConfiguration()
154154
'infiniteScrollEnabled' => $config->isInfiniteScrollEnabled(),
155155
'urlTrackedParameters' => $this->getUrlTrackedParameters(),
156156
'isSearchBoxEnabled' => $config->isInstantSearchBoxEnabled(),
157+
'hidePagination' => $config->hidePaginationInInstantSearchPage()
157158
],
158159
'autocomplete' => [
159160
'enabled' => $config->isAutoCompleteEnabled(),
@@ -381,4 +382,4 @@ protected function getLandingPageConfiguration()
381382
{
382383
return $this->isLandingPage() ? $this->getCurrentLandingPage()->getConfiguration() : json_encode([]);
383384
}
384-
}
385+
}

CHANGELOG.md

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

3+
## 3.10.5
4+
5+
### Bug Fixes
6+
- Added the code to hide Pagination when the results have only one page in InstantSearch page
7+
- Add the code to fix the php8.2 version compatibility issues
8+
- Replaced referenceBlock by referenceContainer following Magento best practices.
9+
- Revert removal of tier price field for product
10+
311
## 3.10.4
412

513
### Bug Fixes

Controller/Adminhtml/Queue/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function execute()
1111
{
1212
$job = $this->initJob();
1313
if (is_null($job)) {
14-
$this->messageManager->addErrorMessage(__('This job does not exists.'));
14+
$this->messageManager->addErrorMessage(__('This job does not exist.'));
1515
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
1616
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
1717

Controller/Adminhtml/QueueArchive/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function execute()
1313
{
1414
$job = $this->initJob();
1515
if (is_null($job)) {
16-
$this->messageManager->addErrorMessage(__('This job does not exists.'));
16+
$this->messageManager->addErrorMessage(__('This job does not exist.'));
1717
/** @var Redirect $resultRedirect */
1818
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
1919

Helper/ConfigHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ConfigHelper
3333
public const XML_ADD_TO_CART_ENABLE = 'algoliasearch_instant/instant/add_to_cart_enable';
3434
public const INFINITE_SCROLL_ENABLE = 'algoliasearch_instant/instant/infinite_scroll_enable';
3535
public const SEARCHBOX_ENABLE = 'algoliasearch_instant/instant/instantsearch_searchbox';
36+
public const HIDE_PAGINATION = 'algoliasearch_instant/instant/hide_pagination';
3637

3738
public const IS_POPUP_ENABLED = 'algoliasearch_autocomplete/autocomplete/is_popup_enabled';
3839
public const NB_OF_PRODUCTS_SUGGESTIONS = 'algoliasearch_autocomplete/autocomplete/nb_of_products_suggestions';
@@ -529,6 +530,16 @@ public function isInfiniteScrollEnabled($storeId = null)
529530
&& $this->configInterface->isSetFlag(self::INFINITE_SCROLL_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
530531
}
531532

533+
/**
534+
* @param $storeId
535+
* @return bool
536+
*/
537+
public function hidePaginationInInstantSearchPage($storeId = null)
538+
{
539+
return $this->isInstantEnabled($storeId)
540+
&& $this->configInterface->isSetFlag(self::HIDE_PAGINATION, ScopeInterface::SCOPE_STORE, $storeId);
541+
}
542+
532543
/**
533544
* @param $storeId
534545
* @return bool

Helper/Entity/PageHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ private function strip($s, $completeRemoveTags = [])
196196
if ($completeRemoveTags && $completeRemoveTags !== [] && $s) {
197197
$dom = new \DOMDocument();
198198
libxml_use_internal_errors(true);
199-
$dom->loadHTML(mb_convert_encoding($s, 'HTML-ENTITIES', 'UTF-8'));
199+
$encodedStr = mb_encode_numericentity($s, [0x80, 0x10fffff, 0, ~0]);
200+
$dom->loadHTML($encodedStr);
200201
libxml_use_internal_errors(false);
201202

202203
$toRemove = [];

Helper/Entity/Product/PriceManager/ProductWithoutChildren.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Catalog\Model\ProductFactory;
1010
use Magento\CatalogRule\Model\ResourceModel\Rule;
1111
use Magento\Customer\Model\Group;
12+
use Magento\Customer\Api\Data\GroupInterface;
1213
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
1314
use Magento\Framework\Pricing\PriceCurrencyInterface;
1415
use Magento\Tax\Helper\Data as TaxHelper;
@@ -110,6 +111,7 @@ public function addPriceData($customData, Product $product, $subProducts): array
110111
$this->customData[$field][$currencyCode]['default'] = $this->priceCurrency->round($price);
111112
$this->customData[$field][$currencyCode]['default_formated'] = $this->formatPrice($price, $currencyCode);
112113
$specialPrice = $this->getSpecialPrice($product, $currencyCode, $withTax);
114+
$tierPrice = $this->getTierPrice($product, $currencyCode, $withTax);
113115
if ($this->areCustomersGroupsEnabled) {
114116
$this->addCustomerGroupsPrices($product, $currencyCode, $withTax, $field);
115117
}
@@ -118,6 +120,7 @@ public function addPriceData($customData, Product $product, $subProducts): array
118120
$this->customData[$field][$currencyCode]['special_to_date'] =
119121
(!empty($product->getSpecialToDate())) ? strtotime($product->getSpecialToDate()) : '';
120122
$this->addSpecialPrices($specialPrice, $field, $currencyCode);
123+
$this->addTierPrices($tierPrice, $field, $currencyCode);
121124
$this->addAdditionalData($product, $withTax, $subProducts, $currencyCode, $field);
122125
}
123126
}
@@ -228,6 +231,96 @@ protected function getSpecialPrice(Product $product, $currencyCode, $withTax): a
228231
}
229232
return $specialPrice;
230233
}
234+
235+
/**
236+
* @param Product $product
237+
* @param $currencyCode
238+
* @param $withTax
239+
* @return array
240+
*/
241+
protected function getTierPrice(Product $product, $currencyCode, $withTax)
242+
{
243+
$tierPrice = [];
244+
$tierPrices = [];
245+
246+
if (!is_null($product->getTierPrices())) {
247+
$product->setData('website_id', $product->getStore()->getWebsiteId());
248+
$productTierPrices = $product->getTierPrices();
249+
foreach ($productTierPrices as $productTierPrice) {
250+
if (!isset($tierPrices[$productTierPrice->getCustomerGroupId()])) {
251+
$tierPrices[$productTierPrice->getCustomerGroupId()] = $productTierPrice->getValue();
252+
253+
continue;
254+
}
255+
256+
$tierPrices[$productTierPrice->getCustomerGroupId()] = min(
257+
$tierPrices[$productTierPrice->getCustomerGroupId()],
258+
$productTierPrice->getValue()
259+
);
260+
}
261+
}
262+
263+
/** @var Group $group */
264+
foreach ($this->groups as $group) {
265+
$groupId = (int) $group->getData('customer_group_id');
266+
$tierPrice[$groupId] = false;
267+
268+
$currentTierPrice = null;
269+
if (!isset($tierPrices[$groupId]) && !isset($tierPrices[GroupInterface::CUST_GROUP_ALL])) {
270+
continue;
271+
}
272+
273+
if (isset($tierPrices[GroupInterface::CUST_GROUP_ALL])
274+
&& $tierPrices[GroupInterface::CUST_GROUP_ALL] !== []) {
275+
$currentTierPrice = $tierPrices[GroupInterface::CUST_GROUP_ALL];
276+
}
277+
278+
if (isset($tierPrices[$groupId]) && $tierPrices[$groupId] !== []) {
279+
$currentTierPrice = $currentTierPrice === null ?
280+
$tierPrices[$groupId] :
281+
min($currentTierPrice, $tierPrices[$groupId]);
282+
}
283+
284+
if ($currencyCode !== $this->baseCurrencyCode) {
285+
$currentTierPrice =
286+
$this->priceCurrency->round($this->convertPrice($currentTierPrice, $currencyCode));
287+
}
288+
$tierPrice[$groupId] = $this->getTaxPrice($product, $currentTierPrice, $withTax);
289+
}
290+
291+
return $tierPrice;
292+
}
293+
294+
/**
295+
* @param $tierPrice
296+
* @param $field
297+
* @param $currencyCode
298+
* @return void
299+
*/
300+
protected function addTierPrices($tierPrice, $field, $currencyCode)
301+
{
302+
if ($this->areCustomersGroupsEnabled) {
303+
/** @var Group $group */
304+
foreach ($this->groups as $group) {
305+
$groupId = (int) $group->getData('customer_group_id');
306+
307+
if ($tierPrice[$groupId]) {
308+
$this->customData[$field][$currencyCode]['group_' . $groupId . '_tier'] = $tierPrice[$groupId];
309+
310+
$this->customData[$field][$currencyCode]['group_' . $groupId . '_tier_formated'] =
311+
$this->formatPrice($tierPrice[$groupId], $currencyCode);
312+
}
313+
}
314+
315+
return;
316+
}
317+
318+
if ($tierPrice[0]) {
319+
$this->customData[$field][$currencyCode]['default_tier'] = $this->priceCurrency->round($tierPrice[0]);
320+
$this->customData[$field][$currencyCode]['default_tier_formated'] =
321+
$this->formatPrice($tierPrice[0], $currencyCode);
322+
}
323+
}
231324

232325
/**
233326
* @param $groupId

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": "3.10.4",
6+
"version": "3.10.5",
77
"require": {
88
"magento/framework": "~102.0|~103.0",
99
"algolia/algoliasearch-client-php": "3.2",

etc/adminhtml/system.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,18 @@
399399
<field id="is_instant_enabled">1</field>
400400
</depends>
401401
</field>
402+
<field id="hide_pagination" translate="label comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
403+
<label>Hide Pagination for Single Page Results</label>
404+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
405+
<comment>
406+
<![CDATA[
407+
Hide Pagination if there is only one page in the results
408+
]]>
409+
</comment>
410+
<depends>
411+
<field id="is_instant_enabled">1</field>
412+
</depends>
413+
</field>
402414
</group>
403415
</section>
404416
<section id="algoliasearch_products" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<sorts><![CDATA[{"_4581608784535_789":{"attribute":"price","sort":"asc","sortLabel":"Lowest price"},"_2541555584535_585":{"attribute":"price","sort":"desc","sortLabel":"Highest price"},"_5581608784535_898":{"attribute":"created_at","sort":"desc","sortLabel":"Newest first"}}]]></sorts>
2121
<instantsearch_searchbox>1</instantsearch_searchbox>
2222
<use_virtual_replica>0</use_virtual_replica>
23+
<hide_pagination>0</hide_pagination>
2324
</instant>
2425
</algoliasearch_instant>
2526
<algoliasearch_products>

0 commit comments

Comments
 (0)