Skip to content

Commit 531663d

Browse files
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into MC-22212
2 parents 0cf9026 + 7d0fc5a commit 531663d

File tree

11 files changed

+451
-24
lines changed

11 files changed

+451
-24
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="Enable3DSecureBraintree">
12+
<data key="path">payment/braintree/verify_3dsecure</data>
13+
<data key="value">1</data>
14+
</entity>
15+
<entity name="Disable3DSecureBraintree">
16+
<data key="path">payment/braintree/verify_3dsecure</data>
17+
<data key="value">0</data>
18+
</entity>
19+
<entity name="DisableVaultBraintree">
20+
<data key="path">payment/braintree_cc_vault/active</data>
21+
<data key="value">0</data>
22+
</entity>
23+
</entities>

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,9 @@ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
17331733
if ($attribute == 'price' && $storeId != 0) {
17341734
$this->addPriceData();
17351735
if ($this->_productLimitationFilters->isUsingPriceIndex()) {
1736-
$this->getSelect()->order("price_index.min_price {$dir}");
1736+
$this->getSelect()->order(
1737+
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$dir}")
1738+
);
17371739
return $this;
17381740
}
17391741
}

app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
1111
<page name="CheckoutPage" url="/checkout" area="storefront" module="Magento_Checkout">
12+
<section name="StorefrontCheckoutPageMessagesSection"/>
1213
<section name="CheckoutShippingSection"/>
1314
<section name="CheckoutShippingMethodsSection"/>
1415
<section name="CheckoutOrderSummarySection"/>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontCheckoutPageMessagesSection">
12+
<element name="successMessage" type="text" selector="//div[@id='checkout']//div[@data-role='checkout-messages']//div[contains(@class,'message-success')]//div[contains(.,'{{message}}')]" parameterized="true"/>
13+
</section>
14+
</sections>

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,22 @@ public function apply()
6969
foreach ($items as $item) {
7070
$ids[] = (int)$item->getId();
7171
}
72-
$this->collection->getSelect()->where('e.entity_id IN (?)', $ids);
73-
$orderList = join(',', $ids);
74-
$this->collection->getSelect()->reset(\Magento\Framework\DB\Select::ORDER);
75-
$this->collection->getSelect()->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
72+
$this->collection->getSelect()
73+
->where('e.entity_id IN (?)', $ids)
74+
->reset(\Magento\Framework\DB\Select::ORDER);
75+
$sortOrder = $this->searchResult->getSearchCriteria()
76+
->getSortOrders();
77+
if (!empty($sortOrder['price']) && $this->collection->getLimitationFilters()->isUsingPriceIndex()) {
78+
$sortDirection = $sortOrder['price'];
79+
$this->collection->getSelect()
80+
->order(
81+
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$sortDirection}")
82+
);
83+
} else {
84+
$orderList = join(',', $ids);
85+
$this->collection->getSelect()
86+
->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
87+
}
7688
}
7789

7890
/**

app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml

Lines changed: 228 additions & 0 deletions
Large diffs are not rendered by default.

app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<group value="braintree"/>
2222
</annotations>
2323
<before>
24+
<magentoCLI command="downloadable:domains:add" arguments="example.com static.magento.com" stepKey="addDownloadableDomain"/>
2425
<!-- Configure Braintree payment method -->
2526
<createData entity="BraintreeConfig" stepKey="configureBraintreePayment"/>
2627
<!-- Enable Braintree with Vault -->
@@ -31,7 +32,6 @@
3132
<createData entity="VirtualProduct" stepKey="createVirtualProduct"/>
3233
<actionGroup ref="AdminCreateApiConfigurableProductActionGroup" stepKey="createConfigurableProduct"/>
3334
<!-- Create Downloadable Product -->
34-
<magentoCLI command="downloadable:domains:add example.com static.magento.com" stepKey="addDownloadableDomain"/>
3535
<createData entity="ApiDownloadableProduct" stepKey="createDownloadableProduct"/>
3636
<createData entity="ApiDownloadableLink" stepKey="addDownloadableLink">
3737
<requiredEntity createDataKey="createDownloadableProduct"/>

dev/tests/integration/testsuite/Magento/Backend/Block/Dashboard/Tab/OrdersTest.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,18 @@ protected function setUp()
4949
* @magentoDataFixture Magento/Sales/_files/order_list_with_invoice.php
5050
* @dataProvider chartUrlDataProvider
5151
* @param string $period
52-
* @param string $expectedAxisRange
5352
* @return void
5453
*/
55-
public function testGetChartUrl(string $period, string $expectedAxisRange): void
54+
public function testGetChartUrl(string $period): void
5655
{
5756
$this->graphBlock->getRequest()->setParams(['period' => $period]);
57+
/** @var Orders $ordersBlock */
5858
$ordersBlock = $this->layout->createBlock(Orders::class);
5959
$decodedChartUrl = urldecode($ordersBlock->getChartUrl());
60-
$this->assertEquals($expectedAxisRange, $this->getUrlParamData($decodedChartUrl, 'chxr'));
60+
$this->assertEquals(
61+
$this->getExpectedAxisRange($ordersBlock),
62+
$this->getUrlParamData($decodedChartUrl, 'chxr')
63+
);
6164
}
6265

6366
/**
@@ -66,11 +69,11 @@ public function testGetChartUrl(string $period, string $expectedAxisRange): void
6669
public function chartUrlDataProvider(): array
6770
{
6871
return [
69-
'Last 24 Hours' => ['24h', '1,0,2,1'],
70-
'Last 7 Days' => ['7d', '1,0,3,1'],
71-
'Current Month' => ['1m', '1,0,3,1'],
72-
'YTD' => ['1y', '1,0,4,1'],
73-
'2YTD' => ['2y', '1,0,4,1'],
72+
'Last 24 Hours' => ['24h'],
73+
'Last 7 Days' => ['7d'],
74+
'Current Month' => ['1m'],
75+
'YTD' => ['1y'],
76+
'2YTD' => ['2y'],
7477
];
7578
}
7679

@@ -91,4 +94,20 @@ private function getUrlParamData(string $chartUrl, string $paramName): string
9194

9295
return '';
9396
}
97+
98+
/**
99+
* @param Orders $ordersBlock
100+
* @return string
101+
*/
102+
private function getExpectedAxisRange(Orders $ordersBlock): string
103+
{
104+
$dashboardOrders = $ordersBlock->getDataHelper()->getItems();
105+
$ordersQty = array_map(function ($order) {
106+
return $order->getQuantity();
107+
}, $dashboardOrders);
108+
109+
$axisPeak = max(array_values($ordersQty)) + 1;
110+
111+
return "1,0,{$axisPeak},1";
112+
}
94113
}

dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListProduct/SortingTest.php

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,7 @@ public function testProductListSortOrder(string $sortBy, string $direction, arra
110110
*/
111111
public function testProductListSortOrderWithConfig(string $sortBy, string $direction, array $expectation): void
112112
{
113-
$this->objectManager->removeSharedInstance(Config::class);
114-
$this->scopeConfig->setValue(
115-
Config::XML_PATH_LIST_DEFAULT_SORT_BY,
116-
$sortBy,
117-
ScopeInterface::SCOPE_STORE,
118-
Store::DEFAULT_STORE_ID
119-
);
120-
$category = $this->updateCategorySortBy('Category 1', Store::DEFAULT_STORE_ID, null);
121-
$this->renderBlock($category, $direction);
122-
$this->assertBlockSorting($sortBy, $expectation);
113+
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expectation);
123114
}
124115

125116
/**
@@ -322,4 +313,89 @@ private function updateCategorySortBy(
322313

323314
return $category;
324315
}
316+
317+
/**
318+
* Test product list ordered by price with out-of-stock configurable product options with elasticsearch engine
319+
*
320+
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
321+
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
322+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
323+
* @magentoConfigFixture default/catalog/search/engine elasticsearch7
324+
* @dataProvider productListWithOutOfStockSortOrderDataProvider
325+
* @param string $sortBy
326+
* @param string $direction
327+
* @param array $expected
328+
* @return void
329+
*/
330+
public function testProductListOutOfStockSortOrderWithElasticsearch(
331+
string $sortBy,
332+
string $direction,
333+
array $expected
334+
): void {
335+
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
336+
}
337+
338+
/**
339+
* Test product list ordered by price with out-of-stock configurable product options with mysql search engine
340+
*
341+
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
342+
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
343+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
344+
* @magentoConfigFixture default/catalog/search/engine mysql
345+
* @dataProvider productListWithOutOfStockSortOrderDataProvider
346+
* @param string $sortBy
347+
* @param string $direction
348+
* @param array $expected
349+
* @return void
350+
*/
351+
public function testProductListOutOfStockSortOrderWithMysql(
352+
string $sortBy,
353+
string $direction,
354+
array $expected
355+
): void {
356+
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
357+
}
358+
359+
/**
360+
* Product list with out-of-stock sort order data provider
361+
*
362+
* @return array
363+
*/
364+
public function productListWithOutOfStockSortOrderDataProvider(): array
365+
{
366+
return [
367+
'default_order_price_asc' => [
368+
'sort' => 'price',
369+
'direction' => Collection::SORT_ORDER_ASC,
370+
'expectation' => ['simple1', 'simple2', 'simple3', 'configurable'],
371+
],
372+
'default_order_price_desc' => [
373+
'sort' => 'price',
374+
'direction' => Collection::SORT_ORDER_DESC,
375+
'expectation' => ['simple3', 'simple2', 'simple1', 'configurable'],
376+
],
377+
];
378+
}
379+
380+
/**
381+
* Assert product list order
382+
*
383+
* @param string $sortBy
384+
* @param string $direction
385+
* @param array $expected
386+
* @return void
387+
*/
388+
private function assertProductListSortOrderWithConfig(string $sortBy, string $direction, array $expected): void
389+
{
390+
$this->objectManager->removeSharedInstance(Config::class);
391+
$this->scopeConfig->setValue(
392+
Config::XML_PATH_LIST_DEFAULT_SORT_BY,
393+
$sortBy,
394+
ScopeInterface::SCOPE_STORE,
395+
Store::DEFAULT_STORE_ID
396+
);
397+
$category = $this->updateCategorySortBy('Category 1', Store::DEFAULT_STORE_ID, null);
398+
$this->renderBlock($category, $direction);
399+
$this->assertBlockSorting($sortBy, $expected);
400+
}
325401
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\CategoryLinkManagementInterface;
9+
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Catalog\Helper\DefaultCategory;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
require __DIR__ . '/product_configurable.php';
14+
15+
$objectManager = Bootstrap::getObjectManager();
16+
17+
/** @var ProductRepositoryInterface $productRepository */
18+
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
19+
20+
$product = $productRepository->get('simple_1010');
21+
$product->setStockData(
22+
[
23+
'qty' => 0,
24+
]
25+
);
26+
$productRepository->save($product);
27+
28+
$product = $productRepository->get('simple_1020');
29+
$product->setStockData(
30+
[
31+
'qty' => 0,
32+
]
33+
);
34+
$productRepository->save($product);
35+
36+
/** @var CategoryLinkManagementInterface $categoryLinkManagement */
37+
$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class);
38+
/** @var DefaultCategory $categoryHelper */
39+
$categoryHelper = $objectManager->get(DefaultCategory::class);
40+
41+
foreach (['simple_1010', 'simple_1020', 'configurable'] as $sku) {
42+
$categoryLinkManagement->assignProductToCategories($sku, [$categoryHelper->getId(), 333]);
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
require __DIR__ . '/../../../Catalog/_files/category_rollback.php';
9+
require __DIR__ . '/product_configurable_rollback.php';

0 commit comments

Comments
 (0)