Skip to content

Commit 2a4e068

Browse files
authored
Merge pull request #1298 from algolia/release/3.10.0
Release/3.10.0
2 parents 96422a7 + 7e64283 commit 2a4e068

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1562
-1039
lines changed

.circleci/config.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ shared: &shared
88
- run:
99
name: Override the Algolia extension with the cloned one
1010
command: |
11-
cd ~/magento_directory/vendor/algolia
12-
rm -rf algoliasearch-magento-2
1311
cp -R ~/build_directory/algoliasearch-magento-2 ~/magento_directory/vendor/algolia
1412
cd ~/magento_directory
13+
sudo composer require algolia/algoliasearch-magento-2
1514
composer dump-autoload
1615
1716
- run:
@@ -29,7 +28,10 @@ shared: &shared
2928
sleep 10
3029
php -dmemory_limit=-1 bin/magento module:disable Magento_WebapiAsync Magento_Amqp Magento_MysqlMq Magento_MessageQueue
3130
php -dmemory_limit=-1 bin/magento module:enable Algolia_AlgoliaSearch
31+
sudo chmod -R 777 var/ pub/ generated/
3232
php -dmemory_limit=-1 bin/magento setup:upgrade
33+
php -dmemory_limit=-1 bin/magento setup:d:c
34+
php -dmemory_limit=-1 bin/magento setup:s:d -f
3335
3436
- run:
3537
name: Get the right tests config for DB and administration
@@ -55,18 +57,17 @@ shared: &shared
5557
cd ~/magento_directory/dev/tests/integration
5658
sudo service elasticsearch start # for some reasons has to be launched with the step
5759
sleep 10
58-
php -dmemory_limit=-1 ../../../vendor/bin/phpunit --debug ../../../vendor/algolia/algoliasearch-magento-2/Test
5960
6061
jobs:
6162
"magento-2.3":
6263
<<: *shared
6364
docker:
64-
- image: algolia/magento2-circleci:v3-2.3.5-p2
65+
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
6566

6667
"magento-2.4":
6768
<<: *shared
6869
docker:
69-
- image: algolia/magento2-circleci:v3-2.4.0
70+
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
7071

7172
"quality-tools":
7273
docker:
@@ -106,6 +107,6 @@ workflows:
106107
version: 2
107108
build:
108109
jobs:
109-
- "magento-2.3"
110110
- "magento-2.4"
111+
- "magento-2.3"
111112
- "quality-tools"

Block/Cart/Recommend.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,23 @@ public function __construct(
4343
*/
4444
public function getAllCartItems()
4545
{
46-
$cartItems = array();
46+
$cartItems = [];
4747
$itemCollection = $this->checkoutSession->getQuote()->getAllVisibleItems();
48-
foreach ( $itemCollection as $item) {
48+
foreach ($itemCollection as $item) {
4949
$cartItems[] = $item->getProductId();
5050
}
5151
return array_unique($cartItems);
5252
}
5353

54-
}
54+
/**
55+
* @return array
56+
*/
57+
public function getAlgoliaRecommendConfiguration()
58+
{
59+
return [
60+
'enabledFBTInCart' => $this->configHelper->isRecommendFrequentlyBroughtTogetherEnabledOnCartPage(),
61+
'enabledRelatedInCart' => $this->configHelper->isRecommendRelatedProductsEnabledOnCartPage(),
62+
'isTrendItemsEnabledInCartPage' => $this->configHelper->isTrendItemsEnabledInShoppingCart()
63+
];
64+
}
65+
}

Block/Configuration.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function getConfiguration()
6969
$path = '';
7070
$level = '';
7171
$categoryId = '';
72+
$parentCategoryName = '';
7273

7374
$addToCartParams = $this->getAddToCartParams();
7475

@@ -94,6 +95,8 @@ public function getConfiguration()
9495
foreach ($category->getPathIds() as $treeCategoryId) {
9596
if ($path !== '') {
9697
$path .= ' /// ';
98+
}else{
99+
$parentCategoryName = $categoryHelper->getCategoryName($treeCategoryId, $this->getStoreId());
97100
}
98101

99102
$path .= $categoryHelper->getCategoryName($treeCategoryId, $this->getStoreId());
@@ -150,6 +153,7 @@ public function getConfiguration()
150153
'addToCartParams' => $addToCartParams,
151154
'infiniteScrollEnabled' => $config->isInfiniteScrollEnabled(),
152155
'urlTrackedParameters' => $this->getUrlTrackedParameters(),
156+
'isSearchBoxEnabled' => $config->isInstantSearchBoxEnabled(),
153157
],
154158
'autocomplete' => [
155159
'enabled' => $config->isAutoCompleteEnabled(),
@@ -159,6 +163,7 @@ public function getConfiguration()
159163
'nbOfCategoriesSuggestions' => $config->getNumberOfCategoriesSuggestions(),
160164
'nbOfQueriesSuggestions' => $config->getNumberOfQueriesSuggestions(),
161165
'isDebugEnabled' => $config->isAutocompleteDebugEnabled(),
166+
'isNavigatorEnabled' => $config->isAutocompleteNavigatorEnabled()
162167
],
163168
'landingPage' => [
164169
'query' => $this->getLandingPageQuery(),
@@ -180,6 +185,9 @@ public function getConfiguration()
180185
'isAddToCartEnabledInFBT' => $config->isAddToCartEnabledInFrequentlyBoughtTogether(),
181186
'isAddToCartEnabledInRelatedProduct' => $config->isAddToCartEnabledInRelatedProducts(),
182187
'isAddToCartEnabledInTrendsItem' => $config->isAddToCartEnabledInTrendsItem(),
188+
'FBTTitle' => __($config->getFBTTitle()),
189+
'relatedProductsTitle' => __($config->getRelatedProductsTitle()),
190+
'trendingItemsTitle' => __($config->getTrendingItemsTitle()),
183191
'addToCartParams' => $addToCartParams,
184192
],
185193
'extensionVersion' => $config->getExtensionVersion(),
@@ -224,6 +232,7 @@ public function getConfiguration()
224232
'landingPageId' => $this->getLandingPageId(),
225233
'path' => $path,
226234
'level' => $level,
235+
'parentCategory' => $parentCategoryName,
227236
],
228237
'showCatsNotIncludedInNavigation' => $config->showCatsNotIncludedInNavigation(),
229238
'showSuggestionsOnNoResultsPage' => $config->showSuggestionsOnNoResultsPage(),
@@ -303,6 +312,9 @@ public function getConfiguration()
303312
'searchBy' => __('Search by'),
304313
'searchForFacetValuesPlaceholder' => __('Search for other ...'),
305314
'showMore' => __('Show more products'),
315+
'searchTitle' => __('Search results for'),
316+
'placeholder' => __('Search for products, categories, ...'),
317+
'addToCart' => __('Add to Cart'),
306318
],
307319
];
308320

@@ -369,4 +381,4 @@ protected function getLandingPageConfiguration()
369381
{
370382
return $this->isLandingPage() ? $this->getCurrentLandingPage()->getConfiguration() : json_encode([]);
371383
}
372-
}
384+
}

Block/RecommendProductView.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Algolia\AlgoliaSearch\Block;
8+
9+
use Magento\Catalog\Model\Product;
10+
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
11+
use Magento\Framework\Registry;
12+
use Magento\Framework\View\Element\Template;
13+
use Magento\Framework\View\Element\Template\Context;
14+
15+
class RecommendProductView extends Template
16+
{
17+
/**
18+
* @var Product
19+
*/
20+
protected $product = null;
21+
22+
/**
23+
* Core registry
24+
*
25+
* @var Registry
26+
*/
27+
protected $coreRegistry = null;
28+
29+
/**
30+
* @var ConfigHelper
31+
*/
32+
protected $configHelper;
33+
34+
/**
35+
* @param Context $context
36+
* @param Registry $registry
37+
* @param ConfigHelper $configHelper
38+
* @param array $data
39+
*/
40+
public function __construct(
41+
Context $context,
42+
Registry $registry,
43+
ConfigHelper $configHelper,
44+
array $data = []
45+
) {
46+
$this->coreRegistry = $registry;
47+
$this->configHelper = $configHelper;
48+
parent::__construct($context, $data);
49+
}
50+
51+
/**
52+
* Returns a Product
53+
*
54+
* @return Product
55+
*/
56+
public function getProduct()
57+
{
58+
if (!$this->product) {
59+
$this->product = $this->coreRegistry->registry('product');
60+
}
61+
return $this->product;
62+
}
63+
64+
/**
65+
* @return array
66+
*/
67+
public function getAlgoliaRecommendConfiguration()
68+
{
69+
return [
70+
'enabledFBT' => $this->configHelper->isRecommendFrequentlyBroughtTogetherEnabled(),
71+
'enabledRelated' => $this->configHelper->isRecommendRelatedProductsEnabled(),
72+
'isTrendItemsEnabledInPDP' => $this->configHelper->isTrendItemsEnabledInPDP()
73+
];
74+
}
75+
}

Block/Widget/TrendsItem.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,37 @@
66
use Magento\Framework\View\Element\Template;
77
use Magento\Framework\View\Element\Template\Context;
88
use Magento\Widget\Block\BlockInterface;
9+
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
910

1011
class TrendsItem extends Template implements BlockInterface
1112
{
13+
/**
14+
* @var ConfigHelper
15+
*/
16+
protected $configHelper;
17+
1218
protected $_template = 'recommend/widget/trends-item.phtml';
13-
19+
1420
/**
1521
* @param Context $context
22+
* @param ConfigHelper $configHelper
1623
* @param Random $mathRandom
1724
* @param array $data
1825
*/
1926
public function __construct(
2027
Context $context,
28+
ConfigHelper $configHelper,
2129
Random $mathRandom,
2230
array $data = []
2331
) {
2432
$this->mathRandom = $mathRandom;
33+
$this->configHelper = $configHelper;
2534
parent::__construct(
2635
$context,
2736
$data
2837
);
2938
}
30-
39+
3140
/**
3241
* @return string
3342
* @throws \Magento\Framework\Exception\LocalizedException
@@ -36,4 +45,12 @@ public function generateUniqueToken()
3645
{
3746
return $this->mathRandom->getRandomString(5);
3847
}
48+
49+
/**
50+
* @return int
51+
*/
52+
public function isTrendingItemEnabled()
53+
{
54+
return $this->configHelper->isRecommendTrendingItemsEnabled();
55+
}
3956
}

CHANGELOG.md

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

3+
4+
## 3.10.0
5+
6+
### UPDATES
7+
- Updated the sorting strategy to select between using Virtual Replica v/s Standard Replica.
8+
- Deprecated the set up of Algolia synonyms from Magento admin
9+
- Updated Algolia Recommend version to 1.8.0 and refactored the corresponding code.
10+
- Added code to delete category from Algolia when the category is deleted from Magento.
11+
- Added keyboard navigation in autocomplete
12+
- Added search input placeholder translation in the autocomplete.
13+
- Added 10 SKU limit in SKU indexing form in the Magento admin.
14+
- Added configuration to enable/disable the searchBox widget on the instant search page.
15+
16+
17+
### FIXES
18+
- Fixed the issue with the price filter in Algolia Merchandiser.
19+
- Fixed the product price issue when the special price and catalog price rules are present.
20+
- Fixed the group price issues for all product types [Simple, Configurable, Bundle, Group, Downloadable, and Virtual Product].
21+
- Fixed the Algolia objectID issue in Recommend
22+
- Fixed the issue on the instant search page where the current search term was not reflecting on the page title.
23+
- Fixed the TagName error in autocomplete.
24+
- Fixed the issue with stock indexing when manage stock is set to No
25+
- Added code to prevent full indexing after placing order when MSI is disabled
26+
27+
328
## 3.9.1
429

530
### UPDATES

Controller/Adminhtml/Landingpage/Save.php

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Algolia\AlgoliaSearch\Controller\Adminhtml\Landingpage;
44

5+
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
56
use Algolia\AlgoliaSearch\Helper\MerchandisingHelper;
67
use Algolia\AlgoliaSearch\Model\LandingPageFactory;
78
use Magento\Framework\App\Request\DataPersistorInterface;
89
use Magento\Framework\Controller\ResultFactory;
910
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Store\Model\StoreManagerInterface;
12+
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
1113

1214
class Save extends AbstractAction
1315
{
@@ -16,6 +18,16 @@ class Save extends AbstractAction
1618
*/
1719
protected $dataPersistor;
1820

21+
/**
22+
* @var CollectionFactory
23+
*/
24+
protected $customerGroupCollectionFactory;
25+
26+
/**
27+
* @var ConfigHelper
28+
*/
29+
protected $configHelper;
30+
1931
/**
2032
* PHP Constructor
2133
*
@@ -25,7 +37,7 @@ class Save extends AbstractAction
2537
* @param MerchandisingHelper $merchandisingHelper
2638
* @param StoreManagerInterface $storeManager
2739
* @param DataPersistorInterface $dataPersistor
28-
*
40+
* @param CollectionFactory $customerGroupCollectionFactory
2941
* @return Save
3042
*/
3143
public function __construct(
@@ -34,10 +46,13 @@ public function __construct(
3446
LandingPageFactory $landingPageFactory,
3547
MerchandisingHelper $merchandisingHelper,
3648
StoreManagerInterface $storeManager,
37-
DataPersistorInterface $dataPersistor
49+
DataPersistorInterface $dataPersistor,
50+
CollectionFactory $customerGroupCollectionFactory,
51+
ConfigHelper $configHelper
3852
) {
3953
$this->dataPersistor = $dataPersistor;
40-
54+
$this->customerGroupCollectionFactory = $customerGroupCollectionFactory;
55+
$this->configHelper = $configHelper;
4156
parent::__construct(
4257
$context,
4358
$coreRegistry,
@@ -84,6 +99,18 @@ public function execute()
8499

85100
if (isset($data['algolia_configuration']) && $data['algolia_configuration'] != $data['configuration']) {
86101
$data['configuration'] = $data['algolia_configuration'];
102+
if ($this->configHelper->isCustomerGroupsEnabled($data['store_id'])) {
103+
$configuration = json_decode($data['algolia_configuration'], true);
104+
$priceConfig = $configuration['price'.$data['price_key']];
105+
$customerGroups = $this->customerGroupCollectionFactory->create();
106+
$store = $this->storeManager->getStore($data['store_id']);
107+
$baseCurrencyCode = $store->getBaseCurrencyCode();
108+
foreach ($customerGroups as $group) {
109+
$groupId = (int) $group->getData('customer_group_id');
110+
$configuration['price.'.$baseCurrencyCode.'.group_'.$groupId] = $priceConfig;
111+
}
112+
$data['configuration'] = json_encode($configuration);
113+
}
87114
}
88115

89116
$landingPage->setData($data);
@@ -120,7 +147,12 @@ public function execute()
120147
return $resultRedirect->setPath('*/*/');
121148
}
122149

123-
private function manageQueryRules($landingPageId, $data)
150+
/**
151+
* @param $landingPageId
152+
* @param $data
153+
* @return void
154+
*/
155+
protected function manageQueryRules($landingPageId, $data)
124156
{
125157
$positions = json_decode($data['algolia_merchandising_positions'], true);
126158
$stores = [];

0 commit comments

Comments
 (0)