Skip to content

Commit f376fcd

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into MAGETWO-52837-command-return-nonzero-on-failure
2 parents 9881180 + 7800e37 commit f376fcd

File tree

184 files changed

+9708
-1089
lines changed

Some content is hidden

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

184 files changed

+9708
-1089
lines changed

app/code/Magento/Braintree/etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</requires>
3434
</field>
3535
<field id="braintree_cc_vault_active" translate="label" type="select" sortOrder="12" showInDefault="1" showInWebsite="1" showInStore="0">
36-
<label>Vault enabled</label>
36+
<label>Vault Enabled</label>
3737
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3838
<config_path>payment/braintree_cc_vault/active</config_path>
3939
<requires>
@@ -155,7 +155,7 @@
155155
<comment>It is recommended to set this value to "PayPal" per store views.</comment>
156156
</field>
157157
<field id="braintree_paypal_vault_active" translate="label" type="select" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="0">
158-
<label>Vault enabled</label>
158+
<label>Vault Enabled</label>
159159
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
160160
<config_path>payment/braintree_paypal_vault/active</config_path>
161161
<requires>

app/code/Magento/Braintree/view/adminhtml/web/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
.braintree-section .heading {display: inline-block; background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
7-
.braintree-section .button-container {display: inline-block; float: right;}
6+
.braintree-section .heading {background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
7+
.braintree-section .button-container {float: right;}
88
.braintree-section .config-alt {background: url("images/braintree_allinone.png") no-repeat scroll 0 0 / 100% auto; height: 28px; margin: 0.5rem 0 0; width: 230px;}

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp)
13171317

13181318
$select = $this->_connection->select()->from(
13191319
$entityTable,
1320-
$this->getNewSkuFieldsForSelect()
1320+
array_merge($this->getNewSkuFieldsForSelect(), $this->getOldSkuFieldsForSelect())
13211321
)->where(
13221322
'sku IN (?)',
13231323
array_keys($entityRowsIn)
@@ -1330,10 +1330,45 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp)
13301330
$this->skuProcessor->setNewSkuData($sku, $key, $value);
13311331
}
13321332
}
1333+
1334+
$this->updateOldSku($newProducts);
13331335
}
1336+
13341337
return $this;
13351338
}
13361339

1340+
/**
1341+
* Return additional data, needed to select.
1342+
* @return array
1343+
*/
1344+
private function getOldSkuFieldsForSelect()
1345+
{
1346+
return ['type_id', 'attribute_set_id'];
1347+
}
1348+
1349+
/**
1350+
* Adds newly created products to _oldSku
1351+
* @param array $newProducts
1352+
* @return void
1353+
*/
1354+
private function updateOldSku(array $newProducts)
1355+
{
1356+
$oldSkus = [];
1357+
foreach ($newProducts as $info) {
1358+
$typeId = $info['type_id'];
1359+
$sku = $info['sku'];
1360+
$oldSkus[$sku] = [
1361+
'type_id' => $typeId,
1362+
'attr_set_id' => $info['attribute_set_id'],
1363+
$this->getProductIdentifierField() => $info[$this->getProductIdentifierField()],
1364+
'supported_type' => isset($this->_productTypeModels[$typeId]),
1365+
$this->getProductEntityLinkField() => $info[$this->getProductEntityLinkField()],
1366+
];
1367+
}
1368+
1369+
$this->_oldSku = array_replace($this->_oldSku, $oldSkus);
1370+
}
1371+
13371372
/**
13381373
* Get new SKU fields for select
13391374
*
@@ -1718,6 +1753,7 @@ protected function _saveProducts()
17181753
['adapter' => $this, 'bunch' => $bunch]
17191754
);
17201755
}
1756+
17211757
return $this;
17221758
}
17231759

@@ -2452,6 +2488,7 @@ protected function _saveValidatedBunches()
24522488
{
24532489
$source = $this->_getSource();
24542490
$source->rewind();
2491+
24552492
while ($source->valid()) {
24562493
try {
24572494
$rowData = $source->current();
@@ -2465,6 +2502,7 @@ protected function _saveValidatedBunches()
24652502
$rowData = $this->_customFieldsMapping($rowData);
24662503

24672504
$this->validateRow($rowData, $source->key());
2505+
24682506
$source->next();
24692507
}
24702508
$this->checkUrlKeyDuplicates();

app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,13 @@ protected function getProductEntityLinkField()
567567
}
568568
return $this->productEntityLinkField;
569569
}
570+
571+
/**
572+
* Clean cached values
573+
*/
574+
public function __destruct()
575+
{
576+
self::$attributeCodeToId = [];
577+
self::$commonAttributesCache = [];
578+
}
570579
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Pricing\Render;
7+
8+
use Magento\Catalog\Pricing\Price\FinalPrice;
9+
use Magento\Catalog\Pricing\Price\RegularPrice;
10+
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
11+
use Magento\Framework\Pricing\Price\PriceInterface;
12+
use Magento\Framework\Pricing\Render\RendererPool;
13+
use Magento\Framework\Pricing\SaleableInterface;
14+
use Magento\Framework\View\Element\Template\Context;
15+
16+
class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
17+
{
18+
/**
19+
* @var ConfigurableOptionsProviderInterface
20+
*/
21+
private $configurableOptionsProvider;
22+
23+
/**
24+
* @param Context $context
25+
* @param SaleableInterface $saleableItem
26+
* @param PriceInterface $price
27+
* @param RendererPool $rendererPool
28+
* @param ConfigurableOptionsProviderInterface $configurableOptionsProvider
29+
* @param array $data
30+
*/
31+
public function __construct(
32+
Context $context,
33+
SaleableInterface $saleableItem,
34+
PriceInterface $price,
35+
RendererPool $rendererPool,
36+
ConfigurableOptionsProviderInterface $configurableOptionsProvider,
37+
array $data = []
38+
) {
39+
$this->configurableOptionsProvider = $configurableOptionsProvider;
40+
parent::__construct($context, $saleableItem, $price, $rendererPool, $data);
41+
}
42+
43+
/**
44+
* Define if the special price should be shown
45+
*
46+
* @return bool
47+
*/
48+
public function hasSpecialPrice()
49+
{
50+
$product = $this->getSaleableItem();
51+
foreach ($this->configurableOptionsProvider->getProducts($product) as $subProduct) {
52+
$regularPrice = $subProduct->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getValue();
53+
$finalPrice = $subProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue();
54+
if ($finalPrice < $regularPrice) {
55+
return true;
56+
}
57+
}
58+
return false;
59+
}
60+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Test\Unit\Pricing\Render;
7+
8+
use Magento\Catalog\Pricing\Price\FinalPrice;
9+
use Magento\Catalog\Pricing\Price\RegularPrice;
10+
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
11+
use Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox;
12+
13+
class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase
14+
{
15+
/**
16+
* @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
private $context;
19+
20+
/**
21+
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $saleableItem;
24+
25+
/**
26+
* @var \Magento\Framework\Pricing\Price\PriceInterface|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
private $price;
29+
30+
/**
31+
* @var \Magento\Framework\Pricing\Render\RendererPool|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $rendererPool;
34+
35+
/**
36+
* @var ConfigurableOptionsProviderInterface|\PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
private $configurableOptionsProvider;
39+
40+
/**
41+
* @var FinalPriceBox
42+
*/
43+
private $model;
44+
45+
protected function setUp()
46+
{
47+
$this->context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
48+
->disableOriginalConstructor()
49+
->getMock();
50+
51+
$this->saleableItem = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
52+
->disableOriginalConstructor()
53+
->getMock();
54+
55+
$this->price = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
56+
->getMockForAbstractClass();
57+
58+
$this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
62+
$this->configurableOptionsProvider = $this->getMockBuilder(ConfigurableOptionsProviderInterface::class)
63+
->getMockForAbstractClass();
64+
65+
$this->model = new FinalPriceBox(
66+
$this->context,
67+
$this->saleableItem,
68+
$this->price,
69+
$this->rendererPool,
70+
$this->configurableOptionsProvider
71+
);
72+
}
73+
74+
/**
75+
* @param float $regularPrice
76+
* @param float $finalPrice
77+
* @param bool $expected
78+
* @dataProvider hasSpecialPriceDataProvider
79+
*/
80+
public function testHasSpecialPrice(
81+
$regularPrice,
82+
$finalPrice,
83+
$expected
84+
) {
85+
$priceMockOne = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
86+
->getMockForAbstractClass();
87+
88+
$priceMockOne->expects($this->once())
89+
->method('getValue')
90+
->willReturn($regularPrice);
91+
92+
$priceMockTwo = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
93+
->getMockForAbstractClass();
94+
95+
$priceMockTwo->expects($this->once())
96+
->method('getValue')
97+
->willReturn($finalPrice);
98+
99+
$priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class)
100+
->disableOriginalConstructor()
101+
->getMock();
102+
103+
$priceInfoMock->expects($this->exactly(2))
104+
->method('getPrice')
105+
->willReturnMap([
106+
[RegularPrice::PRICE_CODE, $priceMockOne],
107+
[FinalPrice::PRICE_CODE, $priceMockTwo],
108+
]);
109+
110+
$productMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
111+
->setMethods(['getPriceInfo'])
112+
->getMockForAbstractClass();
113+
114+
$productMock->expects($this->exactly(2))
115+
->method('getPriceInfo')
116+
->willReturn($priceInfoMock);
117+
118+
$this->configurableOptionsProvider->expects($this->once())
119+
->method('getProducts')
120+
->with($this->saleableItem)
121+
->willReturn([$productMock]);
122+
123+
$this->assertEquals($expected, $this->model->hasSpecialPrice());
124+
}
125+
126+
/**
127+
* @return array
128+
*/
129+
public function hasSpecialPriceDataProvider()
130+
{
131+
return [
132+
[10., 20., false],
133+
[10., 10., false],
134+
[20., 10., true],
135+
];
136+
}
137+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
9+
<referenceBlock name="render.product.prices">
10+
<arguments>
11+
<argument name="configurable" xsi:type="array">
12+
<item name="prices" xsi:type="array">
13+
<item name="final_price" xsi:type="array">
14+
<item name="render_class" xsi:type="string">Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox</item>
15+
<item name="render_template" xsi:type="string">Magento_ConfigurableProduct::product/price/final_price.phtml</item>
16+
</item>
17+
</item>
18+
</argument>
19+
</arguments>
20+
</referenceBlock>
21+
</layout>

0 commit comments

Comments
 (0)