Skip to content

Commit 00affdc

Browse files
MAGE-258 Upgrade DB schema
2 parents cd17987 + 86384ca commit 00affdc

23 files changed

+663
-807
lines changed

.circleci/config.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,14 @@ shared: &shared
5858
php -dmemory_limit=-1 ../../../vendor/bin/phpunit --debug ../../../vendor/algolia/algoliasearch-magento-2/Test
5959
6060
jobs:
61-
"magento-2.3":
62-
<<: *shared
63-
docker:
64-
- image: algolia/magento2-circleci:v3-2.3.5-p2
65-
6661
"magento-2.4":
6762
<<: *shared
6863
docker:
69-
- image: algolia/magento2-circleci:v3-2.4.0
64+
- image: algolia/magento2-circleci:8.1_2.4.4
7065

7166
"quality-tools":
7267
docker:
73-
- image: algolia/magento2-circleci:2.4.4-php7.4-v1
68+
- image: algolia/magento2-circleci:8.1_2.4.4
7469
working_directory: ~/build_directory/algoliasearch-magento-2
7570
steps:
7671
- checkout
@@ -110,6 +105,5 @@ workflows:
110105
version: 2
111106
build:
112107
jobs:
113-
- "magento-2.3"
114108
- "magento-2.4"
115109
- "quality-tools"

Helper/AlgoliaHelper.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,14 +583,15 @@ public function castProductObject(&$productData)
583583
$data = $this->castAttribute($data);
584584

585585
if (is_array($data) === false) {
586-
$data = explode('|', $data);
587-
588-
if (count($data) === 1) {
589-
$data = $data[0];
590-
$data = $this->castAttribute($data);
591-
} else {
592-
foreach ($data as &$element) {
593-
$element = $this->castAttribute($element);
586+
if ($data != null) {
587+
$data = explode('|', $data);
588+
if (count($data) === 1) {
589+
$data = $data[0];
590+
$data = $this->castAttribute($data);
591+
} else {
592+
foreach ($data as &$element) {
593+
$element = $this->castAttribute($element);
594+
}
594595
}
595596
}
596597
}

Helper/ConfigHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ public function getExtraSettings($section, $storeId = null)
750750

751751
$value = $this->configInterface->getValue(constant('self::' . $constant), ScopeInterface::SCOPE_STORE, $storeId);
752752

753-
return trim($value);
753+
return trim((string)$value);
754754
}
755755

756756
public function preventBackendRendering($storeId = null)

Helper/Entity/PageHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private function strip($s, $completeRemoveTags = [])
215215
$s = $dom->saveHTML();
216216
}
217217

218-
$s = html_entity_decode($s, null, 'UTF-8');
218+
$s = html_entity_decode($s, 0, 'UTF-8');
219219

220220
$s = trim(preg_replace('/\s+/', ' ', $s));
221221
$s = preg_replace('/&nbsp;/', ' ', $s);

Helper/Entity/Product/PriceManager/ProductWithoutChildren.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public function addPriceData($customData, Product $product, $subProducts)
8585
}
8686

8787
$this->customData[$field][$currencyCode]['special_from_date'] =
88-
strtotime($product->getSpecialFromDate());
88+
(!empty($product->getSpecialFromDate())) ? strtotime($product->getSpecialFromDate()) : '';
8989
$this->customData[$field][$currencyCode]['special_to_date'] =
90-
strtotime($product->getSpecialToDate());
90+
(!empty($product->getSpecialToDate())) ? strtotime($product->getSpecialToDate()) : '';
9191

9292
$this->addSpecialPrices($specialPrice, $field, $currencyCode);
9393
$this->addTierPrices($tierPrice, $field, $currencyCode);

Model/Indexer/AdditionalSection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function execute($ids)
4242
public function executeFull()
4343
{
4444
if (!$this->configHelper->credentialsAreConfigured()) {
45-
$errorMessage = 'Algolia reindexing failed:
45+
$errorMessage = 'Algolia reindexing failed:
4646
You need to configure your Algolia credentials in Stores > Configuration > Algolia Search.';
4747

4848
if (php_sapi_name() === 'cli') {
@@ -66,7 +66,7 @@ public function executeFull()
6666
$this->queue->addToQueue(
6767
$this->fullAction,
6868
'rebuildStoreAdditionalSectionsIndex',
69-
['store_id' => $storeId],
69+
['storeId' => $storeId],
7070
1
7171
);
7272
}

Model/Indexer/Category.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function execute($categoryIds)
4646
if (!$this->configHelper->getApplicationID()
4747
|| !$this->configHelper->getAPIKey()
4848
|| !$this->configHelper->getSearchOnlyAPIKey()) {
49-
$errorMessage = 'Algolia reindexing failed:
49+
$errorMessage = 'Algolia reindexing failed:
5050
You need to configure your Algolia credentials in Stores > Configuration > Algolia Search.';
5151

5252
if (php_sapi_name() === 'cli') {
@@ -112,8 +112,8 @@ private function rebuildAffectedProducts($storeId)
112112
Data::class,
113113
'rebuildStoreProductIndex',
114114
[
115-
'store_id' => $storeId,
116-
'product_ids' => $chunk,
115+
'storeId' => $storeId,
116+
'productIds' => $chunk,
117117
],
118118
count($chunk)
119119
);
@@ -134,8 +134,8 @@ private function processSpecificCategories($categoryIds, $categoriesPerPage, $st
134134
Data::class,
135135
'rebuildStoreCategoryIndex',
136136
[
137-
'store_id' => $storeId,
138-
'category_ids' => $chunk,
137+
'storeId' => $storeId,
138+
'categoryIds' => $chunk,
139139
],
140140
count($chunk)
141141
);
@@ -152,7 +152,7 @@ private function processSpecificCategories($categoryIds, $categoriesPerPage, $st
152152
private function processFullReindex($storeId, $categoriesPerPage)
153153
{
154154
/** @uses IndicesConfigurator::saveConfigurationToAlgolia() */
155-
$this->queue->addToQueue(IndicesConfigurator::class, 'saveConfigurationToAlgolia', ['store_id' => $storeId]);
155+
$this->queue->addToQueue(IndicesConfigurator::class, 'saveConfigurationToAlgolia', ['storeId' => $storeId]);
156156

157157
$collection = $this->categoryHelper->getCategoryCollectionQuery($storeId);
158158
$size = $collection->getSize();
@@ -161,9 +161,9 @@ private function processFullReindex($storeId, $categoriesPerPage)
161161

162162
for ($i = 1; $i <= $pages; $i++) {
163163
$data = [
164-
'store_id' => $storeId,
164+
'storeId' => $storeId,
165165
'page' => $i,
166-
'page_size' => $categoriesPerPage,
166+
'pageSize' => $categoriesPerPage,
167167
];
168168

169169
/** @uses Data::rebuildCategoryIndex() */

Model/Indexer/Page.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function execute($ids)
4747
if (!$this->configHelper->getApplicationID()
4848
|| !$this->configHelper->getAPIKey()
4949
|| !$this->configHelper->getSearchOnlyAPIKey()) {
50-
$errorMessage = 'Algolia reindexing failed:
50+
$errorMessage = 'Algolia reindexing failed:
5151
You need to configure your Algolia credentials in Stores > Configuration > Algolia Search.';
5252

5353
if (php_sapi_name() === 'cli') {
@@ -69,9 +69,9 @@ public function execute($ids)
6969
}
7070

7171
if ($this->isPagesInAdditionalSections($storeId)) {
72-
$data = ['store_id' => $storeId];
72+
$data = ['storeId' => $storeId];
7373
if (is_array($ids) && count($ids) > 0) {
74-
$data['page_ids'] = $ids;
74+
$data['pageIds'] = $ids;
7575
}
7676

7777
$this->queue->addToQueue(

Model/Indexer/Product.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function execute($productIds)
4949
if (!$this->configHelper->getApplicationID()
5050
|| !$this->configHelper->getAPIKey()
5151
|| !$this->configHelper->getSearchOnlyAPIKey()) {
52-
$errorMessage = 'Algolia reindexing failed:
52+
$errorMessage = 'Algolia reindexing failed:
5353
You need to configure your Algolia credentials in Stores > Configuration > Algolia Search.';
5454

5555
if (php_sapi_name() === 'cli') {
@@ -82,7 +82,7 @@ public function execute($productIds)
8282
$this->queue->addToQueue(
8383
Data::class,
8484
'rebuildStoreProductIndex',
85-
['store_id' => $storeId, 'product_ids' => $chunk],
85+
['storeId' => $storeId, 'productIds' => $chunk],
8686
count($chunk)
8787
);
8888
}
@@ -91,24 +91,22 @@ public function execute($productIds)
9191
}
9292

9393
$useTmpIndex = $this->configHelper->isQueueActive($storeId);
94-
9594
$collection = $this->productHelper->getProductCollectionQuery($storeId, $productIds, $useTmpIndex);
9695
$size = $collection->getSize();
9796

9897
$pages = ceil($size / $productsPerPage);
9998

10099
/** @uses IndicesConfigurator::saveConfigurationToAlgolia() */
101100
$this->queue->addToQueue(IndicesConfigurator::class, 'saveConfigurationToAlgolia', [
102-
'store_id' => $storeId,
101+
'storeId' => $storeId,
103102
'useTmpIndex' => $useTmpIndex,
104103
], 1, true);
105-
106104
for ($i = 1; $i <= $pages; $i++) {
107105
$data = [
108-
'store_id' => $storeId,
109-
'product_ids' => $productIds,
106+
'storeId' => $storeId,
107+
'productIds' => $productIds,
110108
'page' => $i,
111-
'page_size' => $productsPerPage,
109+
'pageSize' => $productsPerPage,
112110
'useTmpIndex' => $useTmpIndex,
113111
];
114112

@@ -123,7 +121,7 @@ public function execute($productIds)
123121
$this->queue->addToQueue(IndexMover::class, 'moveIndexWithSetSettings', [
124122
'tmpIndexName' => $this->fullAction->getIndexName($suffix, $storeId, true),
125123
'indexName' => $this->fullAction->getIndexName($suffix, $storeId),
126-
'store_id' => $storeId,
124+
'storeId' => $storeId,
127125
], 1, true);
128126
}
129127
}

Model/Indexer/Suggestion.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function executeFull()
5151
if (!$this->configHelper->getApplicationID()
5252
|| !$this->configHelper->getAPIKey()
5353
|| !$this->configHelper->getSearchOnlyAPIKey()) {
54-
$errorMessage = 'Algolia reindexing failed:
54+
$errorMessage = 'Algolia reindexing failed:
5555
You need to configure your Algolia credentials in Stores > Configuration > Algolia Search.';
5656

5757
if (php_sapi_name() === 'cli') {
@@ -72,7 +72,7 @@ public function executeFull()
7272
continue;
7373
}
7474

75-
$this->queue->addToQueue($this->fullAction, 'rebuildStoreSuggestionIndex', ['store_id' => $storeId], 1);
75+
$this->queue->addToQueue($this->fullAction, 'rebuildStoreSuggestionIndex', ['storeId' => $storeId], 1);
7676
}
7777
}
7878

0 commit comments

Comments
 (0)