Skip to content

Commit 68bb22b

Browse files
committed
Merge branch 'github-2.3-develop' into MC-15341
2 parents dd9ff5c + bfa0fd4 commit 68bb22b

File tree

14 files changed

+523
-62
lines changed

14 files changed

+523
-62
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ define([
3737
ajax: {
3838
url: options.url,
3939
type: 'POST',
40-
success: $.proxy(function (node) {
41-
return this._convertData(node[0]);
40+
success: $.proxy(function (nodes) {
41+
return this._convertDataNodes(nodes);
4242
}, this),
4343

4444
/**
@@ -77,6 +77,21 @@ define([
7777
}
7878
},
7979

80+
/**
81+
* @param {Array} nodes
82+
* @returns {Array}
83+
* @private
84+
*/
85+
_convertDataNodes: function (nodes) {
86+
var nodesData = [];
87+
88+
nodes.forEach(function (node) {
89+
nodesData.push(this._convertData(node));
90+
}, this);
91+
92+
return nodesData;
93+
},
94+
8095
/**
8196
* @param {Object} node
8297
* @return {*}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
namespace Magento\Cms\Model\Plugin;
9+
10+
use Magento\Catalog\Model\Product as CatalogProduct;
11+
use Magento\Cms\Model\Page;
12+
13+
/**
14+
* Cleaning no-route page cache for the product details page after enabling product that is not assigned to a category
15+
*/
16+
class Product
17+
{
18+
/**
19+
* @var Page
20+
*/
21+
private $page;
22+
23+
/**
24+
* @param Page $page
25+
*/
26+
public function __construct(Page $page)
27+
{
28+
$this->page = $page;
29+
}
30+
31+
/**
32+
* After get identities
33+
*
34+
* @param CatalogProduct $product
35+
* @param array $identities
36+
* @return array
37+
*/
38+
public function afterGetIdentities(CatalogProduct $product, array $identities)
39+
{
40+
if ($product->getOrigData('status') > $product->getData('status')) {
41+
if (empty($product->getCategoryIds())) {
42+
$noRoutePage = $this->page->load(Page::NOROUTE_PAGE_ID);
43+
$noRoutePageId = $noRoutePage->getId();
44+
$identities[] = Page::CACHE_TAG . '_' . $noRoutePageId;
45+
}
46+
}
47+
48+
return array_unique($identities);
49+
}
50+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
namespace Magento\Cms\Test\Unit\Model\Plugin;
9+
10+
use Magento\Catalog\Model\Product as CatalogProduct;
11+
use Magento\Cms\Model\Page;
12+
use Magento\Cms\Model\Plugin\Product;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Product plugin test
19+
*/
20+
class ProductTest extends TestCase
21+
{
22+
/**
23+
* @var Product
24+
*/
25+
private $plugin;
26+
27+
/**
28+
* @var MockObject|CatalogProduct
29+
*/
30+
private $product;
31+
32+
/**
33+
* @var MockObject|Page
34+
*/
35+
private $page;
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
protected function setUp()
41+
{
42+
$objectManager = new ObjectManager($this);
43+
44+
$this->product = $this->getMockBuilder(CatalogProduct::class)
45+
->disableOriginalConstructor()
46+
->setMethods(['getEntityId', 'getOrigData', 'getData', 'getCategoryIds'])
47+
->getMock();
48+
49+
$this->page = $this->getMockBuilder(Page::class)
50+
->disableOriginalConstructor()
51+
->setMethods(['getId', 'load'])
52+
->getMock();
53+
54+
$this->plugin = $objectManager->getObject(
55+
Product::class,
56+
[
57+
'page' => $this->page
58+
]
59+
);
60+
}
61+
62+
public function testAfterGetIdentities()
63+
{
64+
$baseIdentities = [
65+
'SomeCacheId',
66+
'AnotherCacheId',
67+
];
68+
$id = 12345;
69+
$pageId = 1;
70+
$expectedIdentities = [
71+
'SomeCacheId',
72+
'AnotherCacheId',
73+
Page::CACHE_TAG . '_' . $pageId,
74+
];
75+
76+
$this->product->method('getEntityId')
77+
->willReturn($id);
78+
$this->product->method('getOrigData')
79+
->with('status')
80+
->willReturn(2);
81+
$this->product->method('getData')
82+
->with('status')
83+
->willReturn(1);
84+
$this->page->method('getId')
85+
->willReturn(1);
86+
$this->page->method('load')
87+
->willReturnSelf();
88+
89+
$identities = $this->plugin->afterGetIdentities($this->product, $baseIdentities);
90+
91+
$this->assertEquals($expectedIdentities, $identities);
92+
}
93+
}

app/code/Magento/Cms/etc/di.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,7 @@
233233
</argument>
234234
</arguments>
235235
</type>
236+
<type name="Magento\Catalog\Model\Product">
237+
<plugin name="cms" type="Magento\Cms\Model\Plugin\Product" sortOrder="100"/>
238+
</type>
236239
</config>
237-

app/code/Magento/Payment/Helper/Data.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function getStoreMethods($store = null, $quote = null)
149149
}
150150
$res[] = $methodInstance;
151151
}
152-
152+
// phpcs:ignore Generic.PHP.NoSilencedErrors
153153
@uasort(
154154
$res,
155155
function (MethodInterface $a, MethodInterface $b) {
@@ -261,14 +261,12 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit
261261
$groupRelations = [];
262262

263263
foreach ($this->getPaymentMethods() as $code => $data) {
264-
if (!empty($data['active'])) {
265-
$storedTitle = $this->getMethodInstance($code)->getConfigData('title', $store);
266-
if (isset($storedTitle)) {
267-
$methods[$code] = $storedTitle;
268-
} elseif (isset($data['title'])) {
269-
$methods[$code] = $data['title'];
270-
}
264+
$storeId = $store ? (int)$store->getId() : null;
265+
$storedTitle = $this->getMethodStoreTitle($code, $storeId);
266+
if (!empty($storedTitle)) {
267+
$methods[$code] = $storedTitle;
271268
}
269+
272270
if ($asLabelValue && $withGroups && isset($data['group'])) {
273271
$groupRelations[$code] = $data['group'];
274272
}
@@ -350,4 +348,21 @@ public function getZeroSubTotalPaymentAutomaticInvoice($store = null)
350348
$store
351349
);
352350
}
351+
352+
/**
353+
* Get config title of payment method
354+
*
355+
* @param string $code
356+
* @param int|null $storeId
357+
* @return string
358+
*/
359+
private function getMethodStoreTitle(string $code, ?int $storeId = null): string
360+
{
361+
$configPath = sprintf('%s/%s/title', self::XML_PATH_PAYMENT_METHODS, $code);
362+
return (string) $this->scopeConfig->getValue(
363+
$configPath,
364+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
365+
$storeId
366+
);
367+
}
353368
}

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
516516
/* Check if we edit guest order */
517517
$session->setCustomerId($order->getCustomerId() ?: false);
518518
$session->setStoreId($order->getStoreId());
519+
if ($session->getData('reordered')) {
520+
$this->getQuote()->setCustomerGroupId($order->getCustomerGroupId());
521+
}
519522

520523
/* Initialize catalog rule data with new session values */
521524
$this->initRuleData();
@@ -773,7 +776,7 @@ public function getCustomerCompareList()
773776
public function getCustomerGroupId()
774777
{
775778
$groupId = $this->getQuote()->getCustomerGroupId();
776-
if (!$groupId) {
779+
if (!isset($groupId)) {
777780
$groupId = $this->getSession()->getCustomerGroupId();
778781
}
779782

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderItemsOrderedSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<element name="productNameColumn" type="text" selector=".edit-order-table .col-product .product-title"/>
2525
<element name="productNameOptions" type="text" selector=".edit-order-table .col-product .item-options"/>
2626
<element name="productName" type="text" selector="#order-items_grid span[id*=order_item]"/>
27+
<element name="productPrice" type="text" selector=".order-tables tbody td:nth-child({{row}}) .price" parameterized="true"/>
2728
<element name="productNameOptionsLink" type="text" selector="//table[contains(@class, 'edit-order-table')]//td[contains(@class, 'col-product')]//a[text() = '{{var1}}']" parameterized="true"/>
2829
<element name="productSkuColumn" type="text" selector=".edit-order-table .col-product .product-sku-block"/>
2930
<element name="productTotal" type="text" selector="#order-items_grid .col-total"/>

app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</actionGroup>
6262
<!--Reorder-->
6363
<click selector="{{AdminOrderDetailsMainActionsSection.reorder}}" stepKey="clickReorder"/>
64+
<!--Verify order item row-->
65+
<waitForElementVisible selector="{{AdminOrderItemsOrderedSection.productPrice('2')}}" stepKey="waitOrderItemPriceToBeVisible"/>
66+
<see selector="{{AdminOrderItemsOrderedSection.productPrice('2')}}" userInput="${{AdminOrderSimpleProductWithCatalogRule.subtotal}}" stepKey="seeOrderItemPrice"/>
6467
<!--Verify totals on Order page-->
6568
<scrollTo selector="{{AdminOrderFormTotalSection.grandTotal}}" stepKey="scrollToOrderGrandTotal"/>
6669
<waitForElementVisible selector="{{AdminOrderFormTotalSection.total('Subtotal')}}" stepKey="waitOrderSubtotalToBeVisible"/>

0 commit comments

Comments
 (0)