Skip to content

Commit d70883e

Browse files
author
Alexander Akimov
authored
Merge pull request #3807 from magento-tsg/2.2.8-develop-pr81
[TSG] Backporting for 2.2 (pr81) (2.2.8-develop)
2 parents 83cc640 + b605ff2 commit d70883e

File tree

12 files changed

+142
-76
lines changed

12 files changed

+142
-76
lines changed

app/code/Magento/Catalog/Model/Product/ProductFrontendAction/Synchronizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ private function getProductIdsByActions(array $actions)
138138
$productIds = [];
139139

140140
foreach ($actions as $action) {
141-
if (isset($action['product_id']) && is_int($action['product_id'])) {
142-
$productIds[] = $action['product_id'];
141+
if (isset($action['product_id']) && (int)$action['product_id']) {
142+
$productIds[] = (int)$action['product_id'];
143143
}
144144
}
145145

app/code/Magento/Catalog/Test/Unit/Model/Product/ProductFrontendAction/SynchronizerTest.php

Lines changed: 90 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,20 @@ protected function setUp()
7878
);
7979
}
8080

81-
public function testFilterProductActions()
81+
/**
82+
* @dataProvider filterProductActionsDataProvider
83+
*
84+
* @param array $productsData
85+
* @param bool $correct
86+
* @return void
87+
*/
88+
public function testFilterProductActions(array $productsData, bool $correct)
8289
{
83-
$productsData = [
84-
1 => [
85-
'added_at' => 12,
86-
'product_id' => 1,
87-
],
88-
2 => [
89-
'added_at' => 13,
90-
'product_id' => 2,
91-
],
92-
3 => [
93-
'added_at' => 14,
94-
'product_id' => 3,
95-
]
96-
];
9790
$frontendConfiguration = $this->createMock(\Magento\Catalog\Model\FrontendStorageConfigurationInterface::class);
9891
$frontendConfiguration->expects($this->once())
9992
->method('get')
10093
->willReturn([
101-
'lifetime' => 2
94+
'lifetime' => 2,
10295
]);
10396
$this->frontendStorageConfigurationPoolMock->expects($this->once())
10497
->method('get')
@@ -110,7 +103,6 @@ public function testFilterProductActions()
110103
$action2 = $this->getMockBuilder(ProductFrontendActionInterface::class)
111104
->getMockForAbstractClass();
112105

113-
$frontendAction = $this->createMock(ProductFrontendActionInterface::class);
114106
$collection = $this->getMockBuilder(Collection::class)
115107
->disableOriginalConstructor()
116108
->getMock();
@@ -126,47 +118,91 @@ public function testFilterProductActions()
126118
$collection->expects($this->once())
127119
->method('addFilterByUserIdentities')
128120
->with(1, 34);
129-
$collection->expects($this->any())
130-
->method('addFieldToFilter')
131-
->withConsecutive(['type_id'], ['product_id']);
132121

133-
$iterator = new \IteratorIterator(new \ArrayIterator([$frontendAction]));
134-
$collection->expects($this->once())
135-
->method('getIterator')
136-
->willReturn($iterator);
137-
$this->entityManagerMock->expects($this->once())
138-
->method('delete')
139-
->with($frontendAction);
140-
$this->productFrontendActionFactoryMock->expects($this->exactly(2))
141-
->method('create')
142-
->withConsecutive(
143-
[
122+
if ($correct) {
123+
$frontendAction = $this->createMock(ProductFrontendActionInterface::class);
124+
$iterator = new \IteratorIterator(new \ArrayIterator([$frontendAction]));
125+
$collection->expects($this->any())
126+
->method('addFieldToFilter')
127+
->withConsecutive(['type_id'], ['product_id']);
128+
$collection->expects($this->once())
129+
->method('getIterator')
130+
->willReturn($iterator);
131+
$this->entityManagerMock->expects($this->once())
132+
->method('delete')
133+
->with($frontendAction);
134+
$this->entityManagerMock->expects($this->exactly(2))
135+
->method('save')
136+
->withConsecutive([$action1], [$action2]);
137+
$this->productFrontendActionFactoryMock->expects($this->exactly(2))
138+
->method('create')
139+
->withConsecutive(
144140
[
145-
'data' => [
146-
'visitor_id' => null,
147-
'customer_id' => 1,
148-
'added_at' => 12,
149-
'product_id' => 1,
150-
'type_id' => 'recently_compared_product'
151-
]
152-
]
153-
],
154-
[
141+
[
142+
'data' => [
143+
'visitor_id' => null,
144+
'customer_id' => 1,
145+
'added_at' => 12,
146+
'product_id' => 1,
147+
'type_id' => 'recently_compared_product',
148+
],
149+
],
150+
],
155151
[
156-
'data' => [
157-
'visitor_id' => null,
158-
'customer_id' => 1,
159-
'added_at' => 13,
160-
'product_id' => 2,
161-
'type_id' => 'recently_compared_product'
162-
]
152+
[
153+
'data' => [
154+
'visitor_id' => null,
155+
'customer_id' => 1,
156+
'added_at' => 13,
157+
'product_id' => 2,
158+
'type_id' => 'recently_compared_product',
159+
],
160+
],
163161
]
164-
]
165-
)
166-
->willReturnOnConsecutiveCalls($action1, $action2);
167-
$this->entityManagerMock->expects($this->exactly(2))
168-
->method('save')
169-
->withConsecutive([$action1], [$action2]);
162+
)
163+
->willReturnOnConsecutiveCalls($action1, $action2);
164+
} else {
165+
$this->entityManagerMock->expects($this->never())
166+
->method('delete');
167+
$this->entityManagerMock->expects($this->never())
168+
->method('save');
169+
}
170+
170171
$this->model->syncActions($productsData, 'recently_compared_product');
171172
}
173+
174+
/**
175+
* @return array
176+
*/
177+
public function filterProductActionsDataProvider(): array
178+
{
179+
return [
180+
[
181+
'productsData' => [
182+
1 => [
183+
'added_at' => 12,
184+
'product_id' => 1,
185+
],
186+
2 => [
187+
'added_at' => 13,
188+
'product_id' => 2,
189+
],
190+
3 => [
191+
'added_at' => 14,
192+
'product_id' => 3,
193+
],
194+
],
195+
'correct' => true,
196+
],
197+
[
198+
'productsData' => [
199+
1 => [
200+
'added_at' => 12,
201+
'product_id' => 'test',
202+
],
203+
],
204+
'correct' => false,
205+
],
206+
];
207+
}
172208
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
115115
'dataType' => Price::NAME,
116116
'component' => 'Magento_Ui/js/form/components/group',
117117
'label' => __('Price'),
118-
'enableLabel' => true,
118+
'showLabel' => false,
119119
'dataScope' => '',
120120
'additionalClasses' => 'control-grouped',
121121
'sortOrder' => isset($priceMeta['arguments']['data']['config']['sortOrder'])

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/composite/fieldset/options/type/date.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
<?php $_optionId = $_option->getId(); ?>
1313
<div class="admin__field field<?php if ($_option->getIsRequire()) echo ' required _required' ?>">
1414
<label class="label admin__field-label">
15-
<?= $block->escapeHtml($_option->getTitle()) ?>
16-
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
15+
<span>
16+
<?= $block->escapeHtml($_option->getTitle()) ?>
17+
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
18+
</span>
1719
</label>
1820
<div class="admin__field-control control">
1921

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/composite/fieldset/options/type/file.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ require(['prototype'], function(){
6464

6565
<div class="admin__field <?php if ($_option->getIsRequire()) echo ' required _required' ?>">
6666
<label class="admin__field-label label">
67-
<?= $block->escapeHtml($_option->getTitle()) ?>
68-
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
67+
<span>
68+
<?= $block->escapeHtml($_option->getTitle()) ?>
69+
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
70+
</span>
6971
</label>
7072
<div class="admin__field-control control">
7173
<?php if ($_fileExists): ?>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/composite/fieldset/options/type/text.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
<?php $_option = $block->getOption(); ?>
1212
<div class="field admin__field<?php if ($_option->getIsRequire()) echo ' required _required' ?>">
1313
<label class="admin__field-label label">
14-
<?= $block->escapeHtml($_option->getTitle()) ?>
15-
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
14+
<span>
15+
<?= $block->escapeHtml($_option->getTitle()) ?>
16+
<?= /* @escapeNotVerified */ $block->getFormattedPrice() ?>
17+
</span>
1618
</label>
1719
<div class="control admin__field-control">
1820
<?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_FIELD): ?>

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ protected function getColumn(
591591
'formElement' => Container::NAME,
592592
'component' => 'Magento_Ui/js/form/components/group',
593593
'label' => $label,
594+
'showLabel' => false,
594595
'dataScope' => '',
595596
];
596597
$container['children'] = [

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/price-configurable.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ define([
1111

1212
return Abstract.extend({
1313
defaults: {
14-
listens: {
15-
isConfigurable: 'handlePriceValue'
16-
},
1714
imports: {
1815
isConfigurable: '!ns = ${ $.ns }, index = configurable-matrix:isEmpty'
1916
},
@@ -22,12 +19,15 @@ define([
2219
}
2320
},
2421

25-
/**
26-
* Invokes initialize method of parent class,
27-
* contains initialization logic
28-
*/
22+
/** @inheritdoc */
2923
initialize: function () {
3024
this._super();
25+
// resolve initial disable state
26+
this.handlePriceValue(this.isConfigurable);
27+
// add listener to track "configurable" type
28+
this.setListeners({
29+
isConfigurable: 'handlePriceValue'
30+
});
3131

3232
return this;
3333
},
@@ -50,11 +50,10 @@ define([
5050
* @param {String} isConfigurable
5151
*/
5252
handlePriceValue: function (isConfigurable) {
53+
this.disabled(!!this.isUseDefault() || isConfigurable);
54+
5355
if (isConfigurable) {
54-
this.disable();
5556
this.clear();
56-
} else {
57-
this.enable();
5857
}
5958
}
6059
});

app/code/Magento/Sales/Model/Order/Status/History.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getOrder()
142142
*/
143143
public function getStatusLabel()
144144
{
145-
if ($this->getOrder()) {
145+
if ($this->getOrder() && $this->getStatus() !== null) {
146146
return $this->getOrder()->getConfig()->getStatusLabel($this->getStatus());
147147
}
148148
return null;

app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ public function testGetStatusLabel()
8383
$this->assertEquals($status, $this->model->getStatusLabel());
8484
}
8585

86+
/**
87+
* @return void
88+
*/
89+
public function testGetStatusLabelWithNullStatus()
90+
{
91+
$this->model->setOrder($this->order);
92+
$this->model->setStatus(null);
93+
94+
$this->assertNull($this->model->getStatusLabel());
95+
}
96+
8697
public function testGetStoreFromStoreManager()
8798
{
8899
$resultStore = 1;

0 commit comments

Comments
 (0)