Skip to content

Commit 0ccf4c8

Browse files
author
Volodymyr Klymenko
authored
Merge pull request #1092 from magento-tsg/2.1.8-develop-pr7
[TSG] Backporting for 2.1 (pr7) (2.1.8)
2 parents 75a7b9b + 689f28a commit 0ccf4c8

File tree

41 files changed

+1411
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1411
-120
lines changed

app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<item name="config" xsi:type="array">
2424
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
2525
<item name="update_url" xsi:type="url" path="mui/index/render"/>
26+
<item name="storageConfig" xsi:type="array">
27+
<item name="dataScope" xsi:type="string">filters.store_id</item>
28+
</item>
2629
</item>
2730
</argument>
2831
</argument>

app/code/Magento/CatalogWidget/Block/Product/Widget/Conditions.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function __construct(
7373
$this->conditions = $conditions;
7474
$this->rule = $rule;
7575
$this->registry = $registry;
76+
7677
parent::__construct($context, $data);
7778
}
7879

@@ -81,12 +82,17 @@ public function __construct(
8182
*/
8283
protected function _construct()
8384
{
85+
$widgetParameters = [];
8486
$widget = $this->registry->registry('current_widget_instance');
87+
8588
if ($widget) {
8689
$widgetParameters = $widget->getWidgetParameters();
87-
if (isset($widgetParameters['conditions'])) {
88-
$this->rule->loadPost($widgetParameters);
89-
}
90+
} elseif (($widgetOptions = $this->getLayout()->getBlock('wysiwyg_widget.options')) != false) {
91+
$widgetParameters = $widgetOptions->getWidgetValues();
92+
}
93+
94+
if (isset($widgetParameters['conditions'])) {
95+
$this->rule->loadPost($widgetParameters);
9096
}
9197
}
9298

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogWidget\Test\Unit\Block\Product\Widget;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
use Magento\CatalogWidget\Block\Product\Widget\Conditions;
10+
use Magento\Framework\Registry;
11+
use Magento\Backend\Block\Template\Context;
12+
use Magento\CatalogWidget\Model\Rule;
13+
use Magento\Framework\View\LayoutInterface;
14+
use Magento\Framework\View\Element\BlockInterface;
15+
16+
/**
17+
* Test class for \Magento\CatalogWidget\Block\Product\Widget\Conditions
18+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
19+
*/
20+
class ConditionsTest extends \PHPUnit_Framework_TestCase
21+
{
22+
/**
23+
* @var ObjectManagerHelper
24+
*/
25+
private $objectManagerHelper;
26+
27+
/**
28+
* @var Registry|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $registryMock;
31+
32+
/**
33+
* @var Context|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $contextMock;
36+
37+
/**
38+
* @var Rule|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $ruleMock;
41+
42+
/**
43+
* @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
private $layoutMock;
46+
47+
/**
48+
* @var BlockInterface|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
private $blockMock;
51+
52+
/**
53+
* return void
54+
*/
55+
protected function setUp()
56+
{
57+
$this->objectManagerHelper = new ObjectManagerHelper($this);
58+
$this->ruleMock = $this->getMockBuilder(Rule::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
$this->registryMock = $this->getMockBuilder(Registry::class)
62+
->disableOriginalConstructor()
63+
->getMock();
64+
$this->layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
65+
$this->blockMock = $this->getMockBuilder(BlockInterface::class)
66+
->setMethods(['getWidgetValues'])
67+
->getMockForAbstractClass();
68+
$this->contextMock = $this->getMockBuilder(Context::class)
69+
->disableOriginalConstructor()
70+
->getMock();
71+
$this->contextMock->expects($this->once())
72+
->method('getLayout')
73+
->willReturn($this->layoutMock);
74+
}
75+
76+
/**
77+
* @return void
78+
*/
79+
public function testConstructWithEmptyData()
80+
{
81+
$this->registryMock->expects($this->once())
82+
->method('registry')
83+
->with('current_widget_instance')
84+
->willReturn(null);
85+
$this->layoutMock->expects($this->once())
86+
->method('getBlock')
87+
->with('wysiwyg_widget.options')
88+
->willReturn(null);
89+
$this->blockMock->expects($this->never())
90+
->method('getWidgetValues');
91+
$this->ruleMock->expects($this->never())
92+
->method('loadPost');
93+
94+
$this->objectManagerHelper->getObject(
95+
Conditions::class,
96+
[
97+
'context' => $this->contextMock,
98+
'registry' => $this->registryMock,
99+
'rule' => $this->ruleMock,
100+
]
101+
);
102+
}
103+
104+
/**
105+
* @return void
106+
*/
107+
public function testConstructWithWidgetInstance()
108+
{
109+
$widgetParams = ['conditions' => 'some conditions'];
110+
111+
/** @var \Magento\Widget\Model\Widget\Instance|\PHPUnit_Framework_MockObject_MockObject $widgetMock */
112+
$widgetMock = $this->getMockBuilder(\Magento\Widget\Model\Widget\Instance::class)
113+
->disableOriginalConstructor()
114+
->getMock();
115+
$widgetMock->expects($this->once())
116+
->method('getWidgetParameters')
117+
->willReturn($widgetParams);
118+
119+
$this->layoutMock->expects($this->never())
120+
->method('getBlock');
121+
$this->blockMock->expects($this->never())
122+
->method('getWidgetValues');
123+
$this->registryMock->expects($this->once())
124+
->method('registry')
125+
->with('current_widget_instance')
126+
->willReturn($widgetMock);
127+
$this->ruleMock->expects($this->once())
128+
->method('loadPost')
129+
->with($widgetParams)
130+
->willReturnSelf();
131+
132+
$this->objectManagerHelper->getObject(
133+
Conditions::class,
134+
[
135+
'context' => $this->contextMock,
136+
'registry' => $this->registryMock,
137+
'rule' => $this->ruleMock,
138+
]
139+
);
140+
}
141+
142+
/**
143+
* @return void
144+
*/
145+
public function testConstructWithParamsFromBlock()
146+
{
147+
$widgetParams = ['conditions' => 'some conditions'];
148+
149+
$this->registryMock->expects($this->once())
150+
->method('registry')
151+
->with('current_widget_instance')
152+
->willReturn(null);
153+
$this->layoutMock->expects($this->once())
154+
->method('getBlock')
155+
->with('wysiwyg_widget.options')
156+
->willReturn($this->blockMock);
157+
$this->blockMock->expects($this->once())
158+
->method('getWidgetValues')
159+
->willReturn($widgetParams);
160+
$this->ruleMock->expects($this->once())
161+
->method('loadPost')
162+
->with($widgetParams)
163+
->willReturnSelf();
164+
165+
$this->objectManagerHelper->getObject(
166+
Conditions::class,
167+
[
168+
'context' => $this->contextMock,
169+
'registry' => $this->registryMock,
170+
'rule' => $this->ruleMock,
171+
]
172+
);
173+
}
174+
}

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function afterInitialize(Helper $subject, ProductInterface $product)
9595
$product->setAttributeSetId($setId);
9696
}
9797
$extensionAttributes = $product->getExtensionAttributes();
98-
98+
$product->getResource()->getSortedAttributes($setId);
9999
$product->setNewVariationsAttributeSetId($setId);
100100

101101
$configurableOptions = [];

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper;
99
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
1011
use Magento\ConfigurableProduct\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Configurable;
1112
use Magento\ConfigurableProduct\Helper\Product\Options\Factory;
1213
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProduct;
@@ -74,7 +75,7 @@ protected function setUp()
7475
->disableOriginalConstructor()
7576
->setMethods([
7677
'getTypeId', 'setAttributeSetId', 'getExtensionAttributes', 'setNewVariationsAttributeSetId',
77-
'setCanSaveConfigurableAttributes', 'setExtensionAttributes', 'hasData', 'getData'
78+
'setCanSaveConfigurableAttributes', 'setExtensionAttributes', 'hasData', 'getData', 'getResource'
7879
])
7980
->getMock();
8081

@@ -94,6 +95,9 @@ protected function setUp()
9495
*/
9596
public function testAfterInitializeWithAttributesAndVariations()
9697
{
98+
$postValue = 24;
99+
$productResourceMock = $this->getProductResource($postValue);
100+
97101
$attributes = [
98102
['attribute_id' => 90, 'values' => [
99103
['value_index' => 12], ['value_index' => 13]
@@ -152,7 +156,7 @@ public function testAfterInitializeWithAttributesAndVariations()
152156
'configurable-matrix' => $simpleProducts
153157
];
154158
$valueMap = [
155-
['new-variations-attribute-set-id', null, 24],
159+
['new-variations-attribute-set-id', null, $postValue],
156160
['product', [], $productData]
157161
];
158162

@@ -164,20 +168,24 @@ public function testAfterInitializeWithAttributesAndVariations()
164168
->method('getTypeId')
165169
->willReturn(ConfigurableProduct::TYPE_CODE);
166170

167-
$this->product->expects(static::at(4))
171+
$this->product->expects(static::at(5))
168172
->method('hasData')
169173
->with('associated_product_ids')
170174
->willReturn(false);
171-
$this->product->expects(static::at(5))
175+
$this->product->expects(static::at(6))
172176
->method('hasData')
173177
->with('configurable-matrix')
174178
->willReturn(true);
175179

176-
$this->product->expects(static::at(6))
180+
$this->product->expects(static::at(7))
177181
->method('getData')
178182
->with('configurable-matrix')
179183
->willReturn($simpleProducts);
180184

185+
$this->product->expects(static::once())
186+
->method('getResource')
187+
->willReturn($productResourceMock);
188+
181189
$this->request->expects(static::any())
182190
->method('getPost')
183191
->willReturnMap($valueMap);
@@ -225,6 +233,9 @@ public function testAfterInitializeWithAttributesAndVariations()
225233

226234
public function testAfterInitializeWithAttributesAndWithoutVariations()
227235
{
236+
$postValue = 24;
237+
$productResourceMock = $this->getProductResource($postValue);
238+
228239
$attributes = [
229240
['attribute_id' => 90, 'values' => [
230241
['value_index' => 12], ['value_index' => 13]
@@ -238,7 +249,7 @@ public function testAfterInitializeWithAttributesAndWithoutVariations()
238249
];
239250

240251
$valueMap = [
241-
['new-variations-attribute-set-id', null, 24],
252+
['new-variations-attribute-set-id', null, $postValue],
242253
['product', [], $productData],
243254
];
244255
$paramValueMap = [
@@ -254,6 +265,9 @@ public function testAfterInitializeWithAttributesAndWithoutVariations()
254265
$this->product->expects(static::at(0))
255266
->method('getData')
256267
->willReturn(ConfigurableProduct::TYPE_CODE);
268+
$this->product->expects(static::once())
269+
->method('getResource')
270+
->willReturn($productResourceMock);
257271

258272
$this->request->expects(static::any())
259273
->method('getPost')
@@ -331,4 +345,21 @@ public function testAfterInitializeForNotConfigurableProduct()
331345
->method('generateSimpleProducts');
332346
$this->plugin->afterInitialize($this->subject, $this->product);
333347
}
348+
349+
/**
350+
* generate product resource model mock
351+
* @param $postValue
352+
* @return \PHPUnit_Framework_MockObject_MockObject
353+
*/
354+
private function getProductResource($postValue)
355+
{
356+
$productResourceMock = $this->getMockBuilder(ProductResource::class)
357+
->disableOriginalConstructor()
358+
->getMock();
359+
$productResourceMock->expects(static::once())
360+
->method('getSortedAttributes')
361+
->with($postValue);
362+
363+
return $productResourceMock;
364+
}
334365
}

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ protected function _prepareDataForUpdate(array $rowData)
370370

371371
// attribute values
372372
foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) {
373-
if ($newCustomer && !strlen($value)) {
374-
continue;
375-
}
376-
377373
$attributeParameters = $this->_attributes[$attributeCode];
378374
if ('select' == $attributeParameters['type']) {
379375
$value = isset($attributeParameters['options'][strtolower($value)])

app/code/Magento/Sales/Model/Order/Address/Renderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function __construct(
4848
*/
4949
public function format(Address $address, $type)
5050
{
51+
$this->addressConfig->setStore($address->getOrder()->getStoreId());
5152
$formatType = $this->addressConfig->getFormatByCode($type);
5253
if (!$formatType || !$formatType->getRenderer()) {
5354
return null;

0 commit comments

Comments
 (0)