Skip to content

Commit f3856a7

Browse files
authored
Merge pull request #5067 from magento-tsg/2.3.4-develop-pr87
[TSG] Fixes for 2.3 (pr87) (2.3.4-develop)
2 parents 45ed0be + 0640f39 commit f3856a7

File tree

23 files changed

+504
-228
lines changed

23 files changed

+504
-228
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ protected function populateFlatTables(array $stores)
7979
}
8080
$category['store_id'] = $store->getId();
8181
$data[] = $this->prepareValuesToInsert(
82+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
8283
array_merge($category, $attributesData[$category[$linkField]])
8384
);
8485
}
@@ -183,7 +184,7 @@ private function getActualStoreTablesForCategoryFlat(): array
183184
foreach ($this->storeManager->getStores() as $store) {
184185
$actualStoreTables[] = sprintf(
185186
'%s_store_%s',
186-
$this->connection->getTableName('catalog_category_flat'),
187+
$this->connection->getTableName($this->getTableName('catalog_category_flat')),
187188
$store->getId()
188189
);
189190
}
@@ -199,7 +200,7 @@ private function getActualStoreTablesForCategoryFlat(): array
199200
private function deleteAbandonedStoreCategoryFlatTables(): void
200201
{
201202
$existentTables = $this->connection->getTables(
202-
$this->connection->getTableName('catalog_category_flat_store_%')
203+
$this->connection->getTableName($this->getTableName('catalog_category_flat_store_%'))
203204
);
204205
$actualStoreTables = $this->getActualStoreTablesForCategoryFlat();
205206

app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected function _updateRelationProducts($storeId, $productIds = null)
222222
['t' => $this->_productIndexerHelper->getTable($relation->getTable())],
223223
['entity_table.entity_id', $relation->getChildFieldName(), new \Zend_Db_Expr('1')]
224224
)->join(
225-
['entity_table' => $this->_connection->getTableName('catalog_product_entity')],
225+
['entity_table' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
226226
"entity_table.{$metadata->getLinkField()} = t.{$relation->getParentFieldName()}",
227227
[]
228228
)->join(

app/code/Magento/Catalog/Test/Mftf/Data/CatalogStorefrontConfigData.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@
6060
<entity name="DefaultFlatCatalogCategory" type="flat_catalog_category">
6161
<data key="value">0</data>
6262
</entity>
63+
64+
<entity name="DefaultGridPerPageValuesConfigData">
65+
<data key="path">catalog/frontend/grid_per_page_values</data>
66+
<data key="value">12,24,36</data>
67+
</entity>
68+
<entity name="CustomGridPerPageValuesConfigData">
69+
<data key="path">catalog/frontend/grid_per_page_values</data>
70+
<data key="value">1,2</data>
71+
</entity>
6372
</entities>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryBottomToolbarSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="previousPage" type="button" selector=".//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'previous')]" timeout="30"/>
1313
<element name="pageNumber" type="text" selector="//*[@class='toolbar toolbar-products'][2]//a[contains(@class, 'page')]//span[2][contains(text() ,'{{var1}}')]" parameterized="true"/>
1414
<element name="perPage" type="select" selector="//*[@class='toolbar toolbar-products'][2]//select[@id='limiter']"/>
15+
<element name="currentPage" type="text" selector=".products.wrapper + .toolbar-products .pages .current span:nth-of-type(2)"/>
1516
</section>
1617
</sections>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontQuickSearchWithPaginationActionGroup">
12+
<annotations>
13+
<description>Navigate to catalog search page with prepared GET params to get search results with particular page number.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="phrase" type="string" defaultValue="{{_defaultProduct.name}}"/>
17+
<argument name="pageNumber" type="string" defaultValue="1"/>
18+
</arguments>
19+
<amOnPage url="{{StorefrontCatalogSearchPage.url}}?q={{phrase}}&amp;p={{pageNumber}}" stepKey="navigateToCatalogSearchPageWithPreparedRequest"/>
20+
<waitForPageLoad stepKey="waitForCatalogSearchPageLoad"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/DownloadableGraphQl/Model/ResourceModel/GetPurchasedDownloadableProducts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public function execute(int $customerId): array
3939
{
4040
$connection = $this->resourceConnection->getConnection();
4141
$allowedItemsStatuses = [Item::LINK_STATUS_PENDING_PAYMENT, Item::LINK_STATUS_PAYMENT_REVIEW];
42-
$downloadablePurchasedTable = $connection->getTableName('downloadable_link_purchased');
42+
$downloadablePurchasedTable = $this->resourceConnection->getTableName('downloadable_link_purchased');
4343

4444
/* The fields names are hardcoded since there's no existing name reference in the code */
4545
$selectQuery = $connection->select()
4646
->from($downloadablePurchasedTable)
4747
->joinLeft(
48-
['item' => $connection->getTableName('downloadable_link_purchased_item')],
48+
['item' => $this->resourceConnection->getTableName('downloadable_link_purchased_item')],
4949
"$downloadablePurchasedTable.purchased_id = item.purchased_id"
5050
)
5151
->where("$downloadablePurchasedTable.customer_id = ?", $customerId)

app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
285285
'match_mapping_type' => 'string',
286286
'mapping' => [
287287
'type' => 'integer',
288-
'index' => false,
288+
'index' => true,
289289
],
290290
],
291291
],
@@ -296,7 +296,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
296296
'mapping' => $this->prepareFieldInfo(
297297
[
298298
'type' => 'text',
299-
'index' => false,
299+
'index' => true,
300300
]
301301
),
302302
],

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class StaticField implements FieldProviderInterface
6262
*/
6363
private $fieldNameResolver;
6464

65+
/**
66+
* @var array
67+
*/
68+
private $excludedAttributes;
69+
6570
/**
6671
* @param Config $eavConfig
6772
* @param FieldTypeConverterInterface $fieldTypeConverter
@@ -70,6 +75,7 @@ class StaticField implements FieldProviderInterface
7075
* @param FieldIndexResolver $fieldIndexResolver
7176
* @param AttributeProvider $attributeAdapterProvider
7277
* @param FieldName\ResolverInterface|null $fieldNameResolver
78+
* @param array $excludedAttributes
7379
*/
7480
public function __construct(
7581
Config $eavConfig,
@@ -78,7 +84,8 @@ public function __construct(
7884
FieldTypeResolver $fieldTypeResolver,
7985
FieldIndexResolver $fieldIndexResolver,
8086
AttributeProvider $attributeAdapterProvider,
81-
FieldName\ResolverInterface $fieldNameResolver = null
87+
FieldName\ResolverInterface $fieldNameResolver = null,
88+
array $excludedAttributes = []
8289
) {
8390
$this->eavConfig = $eavConfig;
8491
$this->fieldTypeConverter = $fieldTypeConverter;
@@ -88,6 +95,7 @@ public function __construct(
8895
$this->attributeAdapterProvider = $attributeAdapterProvider;
8996
$this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance()
9097
->get(FieldName\ResolverInterface::class);
98+
$this->excludedAttributes = $excludedAttributes;
9199
}
92100

93101
/**
@@ -103,6 +111,9 @@ public function getFields(array $context = []): array
103111
$allAttributes = [];
104112

105113
foreach ($attributes as $attribute) {
114+
if (in_array($attribute->getAttributeCode(), $this->excludedAttributes, true)) {
115+
continue;
116+
}
106117
$attributeAdapter = $this->attributeAdapterProvider->getByAttributeCode($attribute->getAttributeCode());
107118
$fieldName = $this->fieldNameResolver->getFieldName($attributeAdapter);
108119

app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
278278
'match_mapping' => 'string',
279279
'mapping' => [
280280
'type' => 'integer',
281-
'index' => 'no'
281+
'index' => 'not_analyzed',
282282
],
283283
],
284284
],
@@ -288,7 +288,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
288288
'match_mapping' => 'string',
289289
'mapping' => [
290290
'type' => 'string',
291-
'index' => 'no'
291+
'index' => 'not_analyzed',
292292
],
293293
],
294294
]

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function apply()
6060
{
6161
if (empty($this->searchResult->getItems())) {
6262
$this->collection->getSelect()->where('NULL');
63+
6364
return;
6465
}
6566

@@ -85,13 +86,33 @@ public function apply()
8586
private function sliceItems(array $items, int $size, int $currentPage): array
8687
{
8788
if ($size !== 0) {
88-
$offset = ($currentPage - 1) * $size;
89-
if ($offset < 0) {
90-
$offset = 0;
89+
// Check that current page is in a range of allowed page numbers, based on items count and items per page,
90+
// than calculate offset for slicing items array.
91+
$itemsCount = count($items);
92+
$maxAllowedPageNumber = ceil($itemsCount/$size);
93+
if ($currentPage < 1) {
94+
$currentPage = 1;
95+
}
96+
if ($currentPage > $maxAllowedPageNumber) {
97+
$currentPage = $maxAllowedPageNumber;
9198
}
92-
$items = array_slice($items, $offset, $this->size);
99+
100+
$offset = $this->getOffset($currentPage, $size);
101+
$items = array_slice($items, $offset, $size);
93102
}
94103

95104
return $items;
96105
}
106+
107+
/**
108+
* Get offset for given page.
109+
*
110+
* @param int $pageNumber
111+
* @param int $pageSize
112+
* @return int
113+
*/
114+
private function getOffset(int $pageNumber, int $pageSize): int
115+
{
116+
return ($pageNumber - 1) * $pageSize;
117+
}
97118
}

0 commit comments

Comments
 (0)