Skip to content

Commit ff7a70d

Browse files
author
Igor Melnikov
committed
Merge remote-tracking branch 'upstream/develop' into sprint6-pr-new
2 parents 182528e + bbfff31 commit ff7a70d

File tree

117 files changed

+2863
-223
lines changed

Some content is hidden

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

117 files changed

+2863
-223
lines changed

app/code/Magento/Authorizenet/Model/Authorizenet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
332332
->setXCity($billing->getCity())
333333
->setXState($billing->getRegion())
334334
->setXZip($billing->getPostcode())
335-
->setXCountry($billing->getCountry())
335+
->setXCountry($billing->getCountryId())
336336
->setXPhone($billing->getTelephone())
337337
->setXFax($billing->getFax())
338338
->setXCustId($order->getCustomerId())
@@ -352,7 +352,7 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
352352
->setXShipToCity($shipping->getCity())
353353
->setXShipToState($shipping->getRegion())
354354
->setXShipToZip($shipping->getPostcode())
355-
->setXShipToCountry($shipping->getCountry());
355+
->setXShipToCountry($shipping->getCountryId());
356356
}
357357

358358
$request->setXPoNum($payment->getPoNumber())

app/code/Magento/Authorizenet/Model/Directpost/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function setDataFromOrder(
123123
->setXCity(strval($billing->getCity()))
124124
->setXState(strval($billing->getRegion()))
125125
->setXZip(strval($billing->getPostcode()))
126-
->setXCountry(strval($billing->getCountry()))
126+
->setXCountry(strval($billing->getCountryId()))
127127
->setXPhone(strval($billing->getTelephone()))
128128
->setXFax(strval($billing->getFax()))
129129
->setXCustId(strval($billing->getCustomerId()))
@@ -151,7 +151,7 @@ public function setDataFromOrder(
151151
)->setXShipToZip(
152152
strval($shipping->getPostcode())
153153
)->setXShipToCountry(
154-
strval($shipping->getCountry())
154+
strval($shipping->getCountryId())
155155
);
156156
}
157157

app/code/Magento/Braintree/view/adminhtml/web/js/vault.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ define([
2828
self.$selector = $('#' + self.selector);
2929
self.$container = $('#' + self.container);
3030
self.$selector.on(
31-
'setVaultNotActive',
31+
'setVaultNotActive.' + self.getCode(),
3232
function () {
3333
self.$selector.off('submitOrder.' + self.getCode());
3434
}

app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
9494
}
9595
$found = false;
9696
foreach ($existingMediaGalleryEntries as $key => $existingEntry) {
97+
$entryTypes = (array)$entry->getTypes();
98+
$existingEntryTypes = (array)$existingMediaGalleryEntries[$key]->getTypes();
99+
$existingMediaGalleryEntries[$key]->setTypes(array_diff($existingEntryTypes, $entryTypes));
100+
97101
if ($existingEntry->getId() == $entry->getId()) {
98102
$found = true;
99103
if ($entry->getFile()) {
100104
$entry->setId(null);
101105
}
102106
$existingMediaGalleryEntries[$key] = $entry;
103-
break;
104107
}
105108
}
106109
if (!$found) {

app/code/Magento/Catalog/Model/Product/Gallery/Processor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ public function clearMediaAttribute(\Magento\Catalog\Model\Product $product, $me
298298
if (is_array($mediaAttribute)) {
299299
foreach ($mediaAttribute as $attribute) {
300300
if (in_array($attribute, $mediaAttributeCodes)) {
301-
$product->setData($attribute, null);
301+
$product->setData($attribute, 'no_selection');
302302
}
303303
}
304304
} elseif (in_array($mediaAttribute, $mediaAttributeCodes)) {
305-
$product->setData($mediaAttribute, null);
305+
$product->setData($mediaAttribute, 'no_selection');
306306
}
307307

308308
return $this;

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,8 @@ protected function _toHtml()
2929
}
3030

3131
$result = parent::_toHtml();
32-
33-
try {
34-
/** @var MsrpPrice $msrpPriceType */
35-
$msrpPriceType = $this->getSaleableItem()->getPriceInfo()->getPrice('msrp_price');
36-
} catch (\InvalidArgumentException $e) {
37-
$this->_logger->critical($e);
38-
return $this->wrapResult($result);
39-
}
40-
4132
//Renders MSRP in case it is enabled
42-
$product = $this->getSaleableItem();
43-
if ($msrpPriceType->canApplyMsrp($product) && $msrpPriceType->isMinimalPriceLessMsrp($product)) {
33+
if ($this->isMsrpPriceApplicable()) {
4434
/** @var BasePriceBox $msrpBlock */
4535
$msrpBlock = $this->rendererPool->createPriceRender(
4636
MsrpPrice::PRICE_CODE,
@@ -56,6 +46,25 @@ protected function _toHtml()
5646
return $this->wrapResult($result);
5747
}
5848

49+
/**
50+
* Check is MSRP applicable for the current product.
51+
*
52+
* @return bool
53+
*/
54+
protected function isMsrpPriceApplicable()
55+
{
56+
try {
57+
/** @var MsrpPrice $msrpPriceType */
58+
$msrpPriceType = $this->getSaleableItem()->getPriceInfo()->getPrice('msrp_price');
59+
} catch (\InvalidArgumentException $e) {
60+
$this->_logger->critical($e);
61+
return false;
62+
}
63+
64+
$product = $this->getSaleableItem();
65+
return $msrpPriceType->canApplyMsrp($product) && $msrpPriceType->isMinimalPriceLessMsrp($product);
66+
}
67+
5968
/**
6069
* Wrap with standard required container
6170
*

app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,33 @@ public function testUpdate()
191191
$productSku = 'testProduct';
192192
$entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
193193
$entryId = 42;
194+
$entrySecondId = 43;
194195
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
195196
->willReturn($this->productMock);
196197
$existingEntryMock = $this->getMock(
197198
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
198199
);
200+
$existingSecondEntryMock = $this->getMock(
201+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
202+
);
203+
199204
$existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
205+
$existingEntryMock->expects($this->once())->method('getTypes')->willReturn(['small_image']);
206+
$existingEntryMock->expects($this->once())->method('setTypes')->with(['small_image']);
207+
$existingSecondEntryMock->expects($this->once())->method('getId')->willReturn($entrySecondId);
208+
$existingSecondEntryMock->expects($this->once())->method('getTypes')->willReturn(['image']);
209+
$existingSecondEntryMock->expects($this->once())->method('setTypes')->with([]);
200210
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
201-
->willReturn([$existingEntryMock]);
202-
$entryMock->expects($this->once())->method('getId')->willReturn($entryId);
211+
->willReturn([$existingEntryMock, $existingSecondEntryMock]);
212+
213+
$entryMock->expects($this->exactly(2))->method('getId')->willReturn($entryId);
203214
$entryMock->expects($this->once())->method('getFile')->willReturn("base64");
204215
$entryMock->expects($this->once())->method('setId')->with(null);
216+
$entryMock->expects($this->exactly(2))->method('getTypes')->willReturn(['image']);
205217

206218
$this->productMock->expects($this->once())->method('setMediaGalleryEntries')
207-
->willReturn([$entryMock]);
219+
->with([$entryMock, $existingSecondEntryMock])
220+
->willReturnSelf();
208221
$this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock);
209222
$this->assertTrue($this->model->update($productSku, $entryMock));
210223
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,56 @@ public function validateDataProvider()
197197
[false]
198198
];
199199
}
200+
201+
/**
202+
* @param int $setDataExpectsCalls
203+
* @param string|null $setDataArgument
204+
* @param array|string $mediaAttribute
205+
* @dataProvider clearMediaAttributeDataProvider
206+
*/
207+
public function testClearMediaAttribute($setDataExpectsCalls, $setDataArgument, $mediaAttribute)
208+
{
209+
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
210+
->disableOriginalConstructor()
211+
->getMock();
212+
213+
$productMock->expects($this->exactly($setDataExpectsCalls))
214+
->method('setData')
215+
->with($setDataArgument, 'no_selection');
216+
217+
$this->mediaConfig->expects($this->once())
218+
->method('getMediaAttributeCodes')
219+
->willReturn(['image', 'small_image']);
220+
221+
$this->assertSame($this->model, $this->model->clearMediaAttribute($productMock, $mediaAttribute));
222+
}
223+
224+
/**
225+
* @return array
226+
*/
227+
public function clearMediaAttributeDataProvider()
228+
{
229+
return [
230+
[
231+
'setDataExpectsCalls' => 1,
232+
'setDataArgument' => 'image',
233+
'mediaAttribute' => 'image',
234+
],
235+
[
236+
'setDataExpectsCalls' => 1,
237+
'setDataArgument' => 'image',
238+
'mediaAttribute' => ['image'],
239+
],
240+
[
241+
'setDataExpectsCalls' => 0,
242+
'setDataArgument' => null,
243+
'mediaAttribute' => 'some_image',
244+
],
245+
[
246+
'setDataExpectsCalls' => 0,
247+
'setDataArgument' => null,
248+
'mediaAttribute' => ['some_image'],
249+
],
250+
];
251+
}
200252
}

app/code/Magento/CatalogWidget/Model/Rule/Condition/Combine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getNewChildSelectOptions()
8282
public function collectValidatedAttributes($productCollection)
8383
{
8484
foreach ($this->getConditions() as $condition) {
85-
$condition->addToCollection($productCollection);
85+
$condition->collectValidatedAttributes($productCollection);
8686
}
8787
return $this;
8888
}

app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,12 @@ public function getMappedSqlField()
223223

224224
return $result;
225225
}
226+
227+
/**
228+
* {@inheritdoc}
229+
*/
230+
public function collectValidatedAttributes($productCollection)
231+
{
232+
return $this->addToCollection($productCollection);
233+
}
226234
}

0 commit comments

Comments
 (0)