Skip to content

Commit 5cb566a

Browse files
authored
Merge branch 'release/3.11.0-beta' into feature/MAGE-640
2 parents 3487b3c + 87804ae commit 5cb566a

22 files changed

+174
-41
lines changed

Block/Algolia.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,12 @@ public function getLastOrder()
270270
return $this->checkoutSession->getLastRealOrder();
271271
}
272272

273-
public function getAddToCartParams()
273+
public function getAddToCartParams() : array
274274
{
275-
$url = $this->getAddToCartUrl();
276-
277275
return [
278-
'action' => $url,
276+
'action' => $this->_urlBuilder->getUrl('checkout/cart/add', []),
279277
'formKey' => $this->formKey->getFormKey(),
278+
'redirectUrlParam' => ActionInterface::PARAM_NAME_URL_ENCODED
280279
];
281280
}
282281

@@ -285,6 +284,9 @@ public function getTimestamp()
285284
return $this->date->gmtTimestamp('today midnight');
286285
}
287286

287+
/**
288+
* @deprecated This function is deprecated as redirect routes must be derived on the frontend not backend
289+
*/
288290
protected function getAddToCartUrl($additional = [])
289291
{
290292
$continueUrl = $this->urlHelper->getEncodedUrl($this->_urlBuilder->getCurrentUrl());

Block/Configuration.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ public function getConfiguration()
197197
'isVisualMerchEnabled' => $config->isVisualMerchEnabled(),
198198
'categorySeparator' => $config->getCategorySeparator(),
199199
'categoryPageIdAttribute' => $config->getCategoryPageIdAttributeName(),
200-
'isCategoryNavigationEnabled' => self::IS_CATEGORY_NAVIGATION_ENABLED
200+
'isCategoryNavigationEnabled' => self::IS_CATEGORY_NAVIGATION_ENABLED,
201+
'hidePagination' => $config->hidePaginationInInstantSearchPage()
201202
],
202203
'autocomplete' => [
203204
'enabled' => $config->isAutoCompleteEnabled(),
@@ -239,10 +240,7 @@ public function getConfiguration()
239240
'indexName' => $coreHelper->getBaseIndexName(),
240241
'apiKey' => $algoliaHelper->generateSearchSecuredApiKey(
241242
$config->getSearchOnlyAPIKey(),
242-
array_merge(
243-
$config->getAttributesToRetrieve($customerGroupId),
244-
$attributesToFilter
245-
)
243+
$attributesToFilter
246244
),
247245
'attributeFilter' => $attributesToFilter,
248246
'facets' => $facets,
@@ -277,7 +275,8 @@ public function getConfiguration()
277275
'path' => $path,
278276
'level' => $level,
279277
'parentCategory' => $parentCategoryName,
280-
'childCategories' => $childCategories
278+
'childCategories' => $childCategories,
279+
'url' => $this->getUrl('*/*/*', ['_use_rewrite' => true, '_forced_secure' => true])
281280
],
282281
'showCatsNotIncludedInNavigation' => $config->showCatsNotIncludedInNavigation(),
283282
'showSuggestionsOnNoResultsPage' => $config->showSuggestionsOnNoResultsPage(),

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';
@@ -532,6 +533,16 @@ public function isInfiniteScrollEnabled($storeId = null)
532533
&& $this->configInterface->isSetFlag(self::INFINITE_SCROLL_ENABLE, ScopeInterface::SCOPE_STORE, $storeId);
533534
}
534535

536+
/**
537+
* @param $storeId
538+
* @return bool
539+
*/
540+
public function hidePaginationInInstantSearchPage($storeId = null)
541+
{
542+
return $this->isInstantEnabled($storeId)
543+
&& $this->configInterface->isSetFlag(self::HIDE_PAGINATION, ScopeInterface::SCOPE_STORE, $storeId);
544+
}
545+
535546
/**
536547
* @param $storeId
537548
* @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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
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",
9-
"algolia/algoliasearch-client-php": "3.2",
9+
"algolia/algoliasearch-client-php": "3.3.2",
1010
"guzzlehttp/guzzle": "^6.3.3|^7.3.0",
1111
"ext-json": "*",
1212
"ext-PDO": "*",

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">

0 commit comments

Comments
 (0)