Skip to content

Commit f4779eb

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/develop' into pr
2 parents 6fed56b + 81c6cce commit f4779eb

File tree

118 files changed

+3736
-384
lines changed

Some content is hidden

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

118 files changed

+3736
-384
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/Backend/Block/Widget/Grid/Column/Renderer/Text.php

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
7+
8+
use Magento\Framework\DataObject;
69

710
/**
811
* Backend grid item renderer
9-
*
10-
* @author Magento Core Team <core@magentocommerce.com>
1112
*/
12-
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
13-
1413
class Text extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
1514
{
1615
/**
@@ -21,30 +20,53 @@ class Text extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRe
2120
protected $_variablePattern = '/\\$([a-z0-9_]+)/i';
2221

2322
/**
24-
* Renders grid column
23+
* Get value for the cel
2524
*
26-
* @param \Magento\Framework\DataObject $row
27-
* @return mixed
25+
* @param DataObject $row
26+
* @return string
2827
*/
29-
public function _getValue(\Magento\Framework\DataObject $row)
28+
public function _getValue(DataObject $row)
3029
{
31-
$format = $this->getColumn()->getFormat() ? $this->getColumn()->getFormat() : null;
32-
$defaultValue = $this->getColumn()->getDefault();
33-
if ($format === null) {
34-
// If no format and it column not filtered specified return data as is.
35-
$data = parent::_getValue($row);
36-
$string = $data === null ? $defaultValue : $data;
37-
return $this->escapeHtml($string);
38-
} elseif (preg_match_all($this->_variablePattern, $format, $matches)) {
39-
// Parsing of format string
40-
$formattedString = $format;
41-
foreach ($matches[0] as $matchIndex => $match) {
42-
$value = $row->getData($matches[1][$matchIndex]);
43-
$formattedString = str_replace($match, $value, $formattedString);
30+
if (null === $this->getColumn()->getFormat()) {
31+
return $this->getSimpleValue($row);
32+
}
33+
return $this->getFormattedValue($row);
34+
}
35+
36+
/**
37+
* Get simple value
38+
*
39+
* @param DataObject $row
40+
* @return string
41+
*/
42+
private function getSimpleValue(DataObject $row)
43+
{
44+
$data = parent::_getValue($row);
45+
$value = null === $data ? $this->getColumn()->getDefault() : $data;
46+
if (true === $this->getColumn()->getTranslate()) {
47+
$value = __($value);
48+
}
49+
return $this->escapeHtml($value);
50+
}
51+
52+
/**
53+
* Replace placeholders in the string with values
54+
*
55+
* @param DataObject $row
56+
* @return string
57+
*/
58+
private function getFormattedValue(DataObject $row)
59+
{
60+
$value = $this->getColumn()->getFormat() ?: null;
61+
if (true === $this->getColumn()->getTranslate()) {
62+
$value = __($value);
63+
}
64+
if (preg_match_all($this->_variablePattern, $value, $matches)) {
65+
foreach ($matches[0] as $index => $match) {
66+
$replacement = $row->getData($matches[1][$index]);
67+
$value = str_replace($match, $replacement, $value);
4468
}
45-
return $formattedString;
46-
} else {
47-
return $this->escapeHtml($format);
4869
}
70+
return $this->escapeHtml($value);
4971
}
5072
}

app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<argument name="width" xsi:type="string">180</argument>
4949
<argument name="align" xsi:type="string">left</argument>
5050
<argument name="sortable" xsi:type="string">0</argument>
51+
<argument name="translate" xsi:type="boolean">true</argument>
5152
</arguments>
5253
</block>
5354
<block class="Magento\Backend\Block\Widget\Grid\Column" as="description">
@@ -57,6 +58,7 @@
5758
<argument name="type" xsi:type="string">text</argument>
5859
<argument name="align" xsi:type="string">left</argument>
5960
<argument name="sortable" xsi:type="string">0</argument>
61+
<argument name="translate" xsi:type="boolean">true</argument>
6062
</arguments>
6163
</block>
6264
<block class="Magento\Backend\Block\Widget\Grid\Column" as="tags">

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/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ protected function _prepareTierPriceIndex($entityIds = null)
491491
null
492492
)->join(
493493
['e' => $this->getTable('catalog_product_entity')],
494-
"i.entity_id=e.$linkField",
494+
"i.entity_id=e.entity_id",
495495
[]
496496
)->where(
497497
'e.type_id=?',
@@ -502,7 +502,7 @@ protected function _prepareTierPriceIndex($entityIds = null)
502502

503503
$select = $connection->select()->from(
504504
['tp' => $this->getTable('catalog_product_entity_tier_price')],
505-
[$linkField]
505+
['e.entity_id']
506506
)->join(
507507
['e' => $this->getTable('catalog_product_entity')],
508508
"tp.{$linkField} = e.{$linkField}",
@@ -523,11 +523,11 @@ protected function _prepareTierPriceIndex($entityIds = null)
523523
)->columns(
524524
new \Zend_Db_Expr('MIN(tp.value)')
525525
)->group(
526-
["tp.{$linkField}", 'cg.customer_group_id', 'cw.website_id']
526+
['e.entity_id', 'cg.customer_group_id', 'cw.website_id']
527527
);
528528

529529
if (!empty($entityIds)) {
530-
$select->where("tp.{$linkField} IN(?)", $entityIds);
530+
$select->where('e.entity_id IN(?)', $entityIds);
531531
}
532532

533533
$query = $select->insertFromSelect($this->_getTierPriceIndexTable());

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
}

0 commit comments

Comments
 (0)