Skip to content

Commit 2ed8b42

Browse files
committed
Merge branch 'refs/heads/release/3.14.0-beta' into feature/MAGE-941
# Conflicts: # CHANGELOG.md # Helper/ConfigHelper.php
2 parents ee3207f + 42280ae commit 2ed8b42

File tree

22 files changed

+380
-60
lines changed

22 files changed

+380
-60
lines changed

Block/Configuration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ public function getConfiguration()
222222
'enabledRelated' => $config->isRecommendRelatedProductsEnabled(),
223223
'enabledFBTInCart' => $config->isRecommendFrequentlyBroughtTogetherEnabledOnCartPage(),
224224
'enabledRelatedInCart' => $config->isRecommendRelatedProductsEnabledOnCartPage(),
225+
'enabledLookingSimilar' => $config->isRecommendLookingSimilarEnabled(),
225226
'limitFBTProducts' => $config->getNumberOfFrequentlyBoughtTogetherProducts(),
226227
'limitRelatedProducts' => $config->getNumberOfRelatedProducts(),
227228
'limitTrendingItems' => $config->getNumberOfTrendingItems(),
229+
'limitLookingSimilar' => $config->getNumberOfLookingSimilar(),
228230
'enabledTrendItems' => $config->isRecommendTrendingItemsEnabled(),
229231
'trendItemFacetName' => $config->getTrendingItemsFacetName(),
230232
'trendItemFacetValue' => $config->getTrendingItemsFacetValue(),
@@ -233,10 +235,14 @@ public function getConfiguration()
233235
'isAddToCartEnabledInFBT' => $config->isAddToCartEnabledInFrequentlyBoughtTogether(),
234236
'isAddToCartEnabledInRelatedProduct' => $config->isAddToCartEnabledInRelatedProducts(),
235237
'isAddToCartEnabledInTrendsItem' => $config->isAddToCartEnabledInTrendsItem(),
238+
'isAddToCartEnabledInLookingSimilar' => $config->isAddToCartEnabledInLookingSimilar(),
236239
'FBTTitle' => __($config->getFBTTitle()),
237240
'relatedProductsTitle' => __($config->getRelatedProductsTitle()),
238241
'trendingItemsTitle' => __($config->getTrendingItemsTitle()),
239242
'addToCartParams' => $addToCartParams,
243+
'isLookingSimilarEnabledInPDP' => $config->isLookingSimilarEnabledInPDP(),
244+
'isLookingSimilarEnabledInCartPage' => $config->isLookingSimilarEnabledInShoppingCart(),
245+
'lookingSimilarTitle' => __($config->getLookingSimilarTitle())
240246
],
241247
'extensionVersion' => $config->getExtensionVersion(),
242248
'applicationId' => $config->getApplicationID(),

Block/Widget/LookingSimilar.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Algolia\AlgoliaSearch\Block\Widget;
4+
5+
use Magento\Framework\Math\Random;
6+
use Magento\Framework\View\Element\Template;
7+
use Magento\Framework\View\Element\Template\Context;
8+
use Magento\Widget\Block\BlockInterface;
9+
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
10+
11+
class LookingSimilar extends Template implements BlockInterface
12+
{
13+
/**
14+
* @var ConfigHelper
15+
*/
16+
protected $configHelper;
17+
18+
protected $_template = 'recommend/widget/looking-similar.phtml';
19+
20+
/**
21+
* @param Context $context
22+
* @param ConfigHelper $configHelper
23+
* @param Random $mathRandom
24+
* @param array $data
25+
*/
26+
public function __construct(
27+
Context $context,
28+
ConfigHelper $configHelper,
29+
Random $mathRandom,
30+
array $data = []
31+
) {
32+
$this->mathRandom = $mathRandom;
33+
$this->configHelper = $configHelper;
34+
parent::__construct(
35+
$context,
36+
$data
37+
);
38+
}
39+
40+
/**
41+
* @return string
42+
* @throws \Magento\Framework\Exception\LocalizedException
43+
*/
44+
public function generateUniqueToken()
45+
{
46+
return $this->mathRandom->getRandomString(5);
47+
}
48+
49+
/**
50+
* @return string
51+
*/
52+
public function getProductIds()
53+
{
54+
return json_encode(explode(",", $this->getData('productIds')));
55+
}
56+
57+
/**
58+
* @return int
59+
*/
60+
public function isLookingSimilarEnabled()
61+
{
62+
return $this->configHelper->isRecommendLookingSimilarEnabled();
63+
}
64+
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
- Introduced PHP 8 constructor property promotion on affected classes
1919
- Added stronger typing to affected classes and methods
2020

21+
## 3.13.4
22+
23+
### Bug Fixes
24+
- Fixed XSS vulnerability issue in InstantSearch search box
25+
- Fixed Algolia merchandising product listing issue
26+
- Fixed lock timeout issue on indexing queue integration test
27+
- Community fix added - job queue dropping jobs from sandwiched full reindexes - thank you @pikulsky
28+
2129
## 3.14.0-beta.1
2230

2331
### Updates:

Helper/ConfigHelper.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class ConfigHelper
128128
protected const IS_REMOVE_RELATED_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/related_product/is_remove_core_related_products_block';
129129
protected const IS_REMOVE_UPSELL_PRODUCTS_BLOCK = 'algoliasearch_recommend/recommend/frequently_bought_together/is_remove_core_upsell_products_block';
130130
protected const IS_RECOMMEND_TRENDING_ITEMS_ENABLED = 'algoliasearch_recommend/recommend/trends_item/is_trending_items_enabled';
131+
protected const IS_RECOMMEND_LOOKING_SIMILAR_ENABLED = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled';
132+
protected const NUM_OF_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/num_of_products';
131133
protected const NUM_OF_TRENDING_ITEMS = 'algoliasearch_recommend/recommend/trends_item/num_of_trending_items';
132134
protected const TREND_ITEMS_FACET_NAME = 'algoliasearch_recommend/recommend/trends_item/facet_name';
133135
protected const TREND_ITEMS_FACET_VALUE = 'algoliasearch_recommend/recommend/trends_item/facet_value';
@@ -136,6 +138,10 @@ class ConfigHelper
136138
protected const IS_ADDTOCART_ENABLED_IN_FREQUENTLY_BOUGHT_TOGETHER = 'algoliasearch_recommend/recommend/frequently_bought_together/is_addtocart_enabled';
137139
protected const IS_ADDTOCART_ENABLED_IN_RELATED_PRODUCTS = 'algoliasearch_recommend/recommend/related_product/is_addtocart_enabled';
138140
protected const IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM = 'algoliasearch_recommend/recommend/trends_item/is_addtocart_enabled';
141+
protected const IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR = 'algoliasearch_recommend/recommend/looking_similar/is_addtocart_enabled';
142+
protected const IS_LOOKING_SIMILAR_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_pdp';
143+
protected const IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_cart_page';
144+
protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
139145
protected const USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica'; //legacy config
140146
protected const AUTOCOMPLETE_KEYBORAD_NAVIAGATION = 'algoliasearch_autocomplete/autocomplete/navigator';
141147
protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
@@ -744,6 +750,21 @@ public function getNumberOfTrendingItems($storeId = null)
744750
);
745751
}
746752

753+
/**
754+
* Returns number of looking similar products to display
755+
*
756+
* @param $storeId
757+
* @return int
758+
*/
759+
public function getNumberOfLookingSimilar($storeId = null)
760+
{
761+
return (int)$this->configInterface->getValue(
762+
self::NUM_OF_LOOKING_SIMILAR,
763+
ScopeInterface::SCOPE_STORE,
764+
$storeId
765+
);
766+
}
767+
747768
/**
748769
* @param $storeId
749770
* @return mixed
@@ -770,6 +791,57 @@ public function getTrendingItemsFacetValue($storeId = null)
770791
);
771792
}
772793

794+
/**
795+
* Determines whether Looking Similar enabled (for widgets))
796+
*
797+
* @param $storeId
798+
* @return int
799+
*/
800+
public function isRecommendLookingSimilarEnabled($storeId = null)
801+
{
802+
return (int)$this->configInterface->getValue(
803+
self::IS_RECOMMEND_LOOKING_SIMILAR_ENABLED,
804+
ScopeInterface::SCOPE_STORE,
805+
$storeId
806+
);
807+
}
808+
809+
/**
810+
* Determines whether Looking Similar enabled on PDP
811+
*
812+
* @param $storeId
813+
* @return int
814+
*/
815+
public function isLookingSimilarEnabledInPDP($storeId = null)
816+
{
817+
return (int)$this->configInterface->getValue(
818+
self::IS_LOOKING_SIMILAR_ENABLED_IN_PDP,
819+
ScopeInterface::SCOPE_STORE,
820+
$storeId
821+
);
822+
}
823+
824+
public function getLookingSimilarTitle($storeId = null)
825+
{
826+
return $this->configInterface->getValue(
827+
self::LOOKING_SIMILAR_TITLE,
828+
ScopeInterface::SCOPE_STORE, $storeId
829+
);
830+
}
831+
832+
/**
833+
* @param $storeId
834+
* @return int
835+
*/
836+
public function isLookingSimilarEnabledInShoppingCart($storeId = null)
837+
{
838+
return (int)$this->configInterface->getValue(
839+
self::IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART,
840+
ScopeInterface::SCOPE_STORE,
841+
$storeId
842+
);
843+
}
844+
773845
/**
774846
* @param $storeId
775847
* @return int
@@ -823,6 +895,21 @@ public function isAddToCartEnabledInTrendsItem($storeId = null)
823895
return $this->configInterface->isSetFlag(self::IS_ADDTOCART_ENABLED_IN_TRENDS_ITEM, ScopeInterface::SCOPE_STORE, $storeId);
824896
}
825897

898+
/**
899+
* Determines whether add to cart is enabled in Looking Similar
900+
*
901+
* @param $storeId
902+
* @return bool
903+
*/
904+
public function isAddToCartEnabledInLookingSimilar($storeId = null)
905+
{
906+
return $this->configInterface->isSetFlag(
907+
self::IS_ADDTOCART_ENABLED_IN_LOOKING_SIMILAR,
908+
ScopeInterface::SCOPE_STORE,
909+
$storeId
910+
);
911+
}
912+
826913
/**
827914
* @param $storeId
828915
* @return string

Model/Queue.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,12 @@ protected function getJobs($maxJobs)
401401

402402
if ($jobsCount > 0 && $jobsCount < $maxJobs) {
403403
$restLimit = $maxJobs - $jobsCount;
404-
$lastFullReindexJobId = max($this->getJobsIdsFromMergedJobs($jobs));
404+
405+
if ($fullReindexJobsCount > 0) {
406+
$lastFullReindexJobId = max($this->getJobsIdsFromMergedJobs($fullReindexJobs));
407+
} else {
408+
$lastFullReindexJobId = max($this->getJobsIdsFromMergedJobs($jobs));
409+
}
405410

406411
$restFullReindexJobs = $this->fetchJobs($restLimit, true, $lastFullReindexJobId);
407412

README.md

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

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

7-
![PHP](https://img.shields.io/badge/PHP-8.2%2C8.1%2C7.4-blue)
7+
![PHP](https://img.shields.io/badge/PHP-8.1%2C8.2%2C8.3-blue)
88

99
[![CircleCI](https://circleci.com/gh/algolia/algoliasearch-magento-2/tree/master.svg?style=svg)](https://circleci.com/gh/algolia/algoliasearch-magento-2/tree/master)
1010

Test/Integration/QueueTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public function setUp(): void
3030

3131
$this->jobsCollectionFactory = $this->getObjectManager()->create(JobsCollectionFactory::class);
3232

33-
/** @var ResourceConnection $resouce */
34-
$resouce = $this->getObjectManager()->create(ResourceConnection::class);
35-
$this->connection = $resouce->getConnection();
33+
/** @var ResourceConnection $resource */
34+
$resource = $this->getObjectManager()->create(ResourceConnection::class);
35+
$this->connection = $resource->getConnection();
3636

3737
$this->queue = $this->getObjectManager()->create(Queue::class);
3838
}
@@ -135,6 +135,9 @@ public function testExecute()
135135
$this->assertEquals(0, count($rows)); */
136136
}
137137

138+
/**
139+
* @magentoDbIsolation disabled
140+
*/
138141
public function testSettings()
139142
{
140143
$this->markTestIncomplete(self::INCOMPLETE_REASON);
@@ -810,7 +813,7 @@ public function testHugeJob()
810813
{
811814
// Default value - maxBatchSize = 1000
812815
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
813-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
816+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
814817

815818
$productIds = range(1, 5000);
816819
$jsonProductIds = json_encode($productIds);

ViewModel/Recommend/Cart.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Cart implements ArgumentInterface
1616
* @var StoreManagerInterface
1717
*/
1818
protected $storeManager;
19-
19+
2020
/**
2121
* @var Session
2222
*/
@@ -81,7 +81,8 @@ public function getAlgoliaRecommendConfiguration()
8181
return [
8282
'enabledFBTInCart' => $this->configHelper->isRecommendFrequentlyBroughtTogetherEnabledOnCartPage(),
8383
'enabledRelatedInCart' => $this->configHelper->isRecommendRelatedProductsEnabledOnCartPage(),
84-
'isTrendItemsEnabledInCartPage' => $this->configHelper->isTrendItemsEnabledInShoppingCart()
84+
'isTrendItemsEnabledInCartPage' => $this->configHelper->isTrendItemsEnabledInShoppingCart(),
85+
'isLookingSimilarEnabledInCartPage' => $this->configHelper->isLookingSimilarEnabledInShoppingCart()
8586
];
8687
}
8788
}

ViewModel/Recommend/ProductView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function getAlgoliaRecommendConfiguration()
6767
return [
6868
'enabledFBT' => $this->configHelper->isRecommendFrequentlyBroughtTogetherEnabled(),
6969
'enabledRelated' => $this->configHelper->isRecommendRelatedProductsEnabled(),
70-
'isTrendItemsEnabledInPDP' => $this->configHelper->isTrendItemsEnabledInPDP()
70+
'isTrendItemsEnabledInPDP' => $this->configHelper->isTrendItemsEnabledInPDP(),
71+
'isLookingSimilarEnabledInPDP' => $this->configHelper->isLookingSimilarEnabledInPDP()
7172
];
7273
}
7374
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": ["MIT"],
66
"version": "3.14.0-beta.2",
77
"require": {
8-
"php": "~8.1|~8.2",
8+
"php": "~8.1|~8.2|~8.3",
99
"magento/framework": "~102.0|~103.0",
1010
"algolia/algoliasearch-client-php": "^4.0@beta",
1111
"guzzlehttp/guzzle": "^6.3.3|^7.3.0",

0 commit comments

Comments
 (0)