Skip to content

Commit bedf5c1

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.1-develop
Accepted Public Pull Requests: - #15287: [Backport] Handle empty or incorrect lines in a language CSV (by @VitaliyBoyko) - #15860: [Backport] ISSUE-14747 Newsletter subscription confirmation message does not dis� (by @rahul-kachhadiya) - #15236: [Backport] Add price calculation improvement for product option value price (by @VitaliyBoyko) - #15821: [Backport] #14063 - Wrong invoice prefix in multistore setup due to default stor� (by @sanjay-wagento) - #15289: [Backport] Naming collision in Javascript ui registry (backend) (by @VitaliyBoyko) - #15699: [Backport] Variant product image in sidebar wishlist block (by @dmytro-ch) - #15722: [Backport] Fix Magento_ImportExport not supporting unicode characters in column names (by @tdgroot) Fixed GitHub Issues: - #14747: Newsletter subscription confirmation message does not display after clicking link in email (reported by @tohann) has been fixed in #15860 by @rahul-kachhadiya in 2.1-develop branch Related commits: 1. 1839f97
2 parents 76dad58 + a6b0d37 commit bedf5c1

File tree

14 files changed

+165
-16
lines changed

14 files changed

+165
-16
lines changed

app/code/Magento/Catalog/Model/Product/Option/Value.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Catalog\Model\Product\Option;
1010

11+
use Magento\Catalog\Pricing\Price\BasePrice;
1112
use Magento\Framework\Model\AbstractModel;
1213
use Magento\Catalog\Model\Product;
1314
use Magento\Catalog\Model\Product\Option;
@@ -225,7 +226,7 @@ public function saveValues()
225226
public function getPrice($flag = false)
226227
{
227228
if ($flag && $this->getPriceType() == self::TYPE_PERCENT) {
228-
$basePrice = $this->getOption()->getProduct()->getFinalPrice();
229+
$basePrice = $this->getOption()->getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
229230
$price = $basePrice * ($this->_getData(self::KEY_PRICE) / 100);
230231
return $price;
231232
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,30 @@ private function getMockedOption()
170170
private function getMockedProduct()
171171
{
172172
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
173-
->setMethods(['getFinalPrice', '__wakeup'])
173+
->setMethods(['getPriceInfo', '__wakeup'])
174174
->disableOriginalConstructor();
175175
$mock = $mockBuilder->getMock();
176176

177177
$mock->expects($this->any())
178178
->method('getFinalPrice')
179179
->will($this->returnValue(10));
180+
$priceInfoMock = $this->getMockForAbstractClass(
181+
\Magento\Framework\Pricing\PriceInfoInterface::class,
182+
[],
183+
'',
184+
false,
185+
false,
186+
true,
187+
['getPrice']
188+
);
189+
190+
$priceMock = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Price\PriceInterface::class);
191+
192+
$priceInfoMock->expects($this->any())->method('getPrice')->willReturn($priceMock);
193+
194+
$mock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
195+
196+
$priceMock->expects($this->any())->method('getValue')->willReturn(10);
180197

181198
return $mock;
182199
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ define([
276276
var element;
277277

278278
_.each(this.disabledAttributes, function (attribute) {
279-
registry.get('index = ' + attribute).disabled(false);
279+
registry.get('code = ' + attribute, 'index = ' + attribute).disabled(false);
280280
});
281281
this.disabledAttributes = [];
282282

283283
_.each(attributes, function (attribute) {
284-
element = registry.get('index = ' + attribute.code);
284+
element = registry.get('code = ' + attribute.code, 'index = ' + attribute.code);
285285
if (!_.isUndefined(element)) {
286286
element.disabled(true);
287287
this.disabledAttributes.push(attribute.code);

app/code/Magento/ImportExport/Model/Import/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public function validateData()
803803
if (!$this->isAttributeParticular($columnName)) {
804804
if (trim($columnName) == '') {
805805
$emptyHeaderColumns[] = $columnNumber;
806-
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
806+
} elseif (!preg_match('/^[a-z][\w]*$/u', $columnName)) {
807807
$invalidColumns[] = $columnName;
808808
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
809809
$invalidAttributes[] = $columnName;

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ public function validateData()
769769
if (!$this->isAttributeParticular($columnName)) {
770770
if (trim($columnName) == '') {
771771
$emptyHeaderColumns[] = $columnNumber;
772-
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
772+
} elseif (!preg_match('/^[a-z][\w]*$/u', $columnName)) {
773773
$invalidColumns[] = $columnName;
774774
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
775775
$invalidAttributes[] = $columnName;

app/code/Magento/Newsletter/Controller/Subscriber/Confirm.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function execute()
3232
}
3333
}
3434

35-
$this->getResponse()->setRedirect($this->_storeManager->getStore()->getBaseUrl());
35+
$resultRedirect = $this->resultRedirectFactory->create();
36+
$resultRedirect->setUrl($this->_storeManager->getStore()->getBaseUrl());
37+
return $resultRedirect;
3638
}
3739
}

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function getReservedOrderId($quote)
171171
{
172172
return $this->sequenceManager->getSequence(
173173
\Magento\Sales\Model\Order::ENTITY,
174-
$quote->getStore()->getGroup()->getDefaultStoreId()
174+
$quote->getStoreId()
175175
)
176176
->getNextValue();
177177
}
@@ -230,13 +230,24 @@ public function markQuotesRecollectOnCatalogRules()
230230
return $this;
231231
}
232232

233+
/**
234+
* @param \Magento\Catalog\Model\Product $product
235+
* @return Quote
236+
* @deprecated
237+
* @see subtractProductFromQuotes
238+
*/
239+
public function substractProductFromQuotes($product)
240+
{
241+
return $this->subtractProductFromQuotes($product);
242+
}
243+
233244
/**
234245
* Subtract product from all quotes quantities
235246
*
236247
* @param \Magento\Catalog\Model\Product $product
237248
* @return $this
238249
*/
239-
public function substractProductFromQuotes($product)
250+
public function subtractProductFromQuotes($product)
240251
{
241252
$productId = (int)$product->getId();
242253
if (!$productId) {
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Quote\Test\Unit\Model\ResourceModel;
8+
9+
use Magento\Framework\DB\Sequence\SequenceInterface;
10+
use Magento\Framework\Model\ResourceModel\Db\Context;
11+
use Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite;
12+
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
13+
use Magento\Quote\Model\Quote;
14+
use Magento\SalesSequence\Model\Manager;
15+
16+
class QuoteTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $quoteMock;
22+
23+
/**
24+
* @var Manager|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $sequenceManagerMock;
27+
28+
/**
29+
* @var SequenceInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $sequenceMock;
32+
33+
/**
34+
* @var \Magento\Quote\Model\ResourceModel\Quote
35+
*/
36+
private $quote;
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protected function setUp()
42+
{
43+
$context = $this->getMockBuilder(Context::class)
44+
->disableOriginalConstructor()
45+
->getMock();
46+
$snapshot = $this->getMockBuilder(Snapshot::class)
47+
->disableOriginalConstructor()
48+
->getMock();
49+
$relationComposite = $this->getMockBuilder(RelationComposite::class)
50+
->disableOriginalConstructor()
51+
->getMock();
52+
$this->quoteMock = $this->getMockBuilder(Quote::class)
53+
->disableOriginalConstructor()
54+
->getMock();
55+
$this->sequenceManagerMock = $this->getMockBuilder(Manager::class)
56+
->disableOriginalConstructor()
57+
->getMock();
58+
$this->sequenceMock = $this->getMockBuilder(SequenceInterface::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
$this->quote = new \Magento\Quote\Model\ResourceModel\Quote(
62+
$context,
63+
$snapshot,
64+
$relationComposite,
65+
$this->sequenceManagerMock,
66+
null
67+
);
68+
}
69+
70+
/**
71+
* @param $entityType
72+
* @param $storeId
73+
* @param $reservedOrderId
74+
* @dataProvider getReservedOrderIdDataProvider
75+
*/
76+
public function testGetReservedOrderId($entityType, $storeId, $reservedOrderId)
77+
{
78+
$this->sequenceManagerMock->expects($this->once())
79+
->method('getSequence')
80+
->with($entityType, $storeId)
81+
->willReturn($this->sequenceMock);
82+
$this->quoteMock->expects($this->once())
83+
->method('getStoreId')
84+
->willReturn($storeId);
85+
$this->sequenceMock->expects($this->once())
86+
->method('getNextValue')
87+
->willReturn($reservedOrderId);
88+
$this->assertEquals($reservedOrderId, $this->quote->getReservedOrderId($this->quoteMock));
89+
}
90+
91+
/**
92+
* @return array
93+
*/
94+
public function getReservedOrderIdDataProvider()
95+
{
96+
return [
97+
[\Magento\Sales\Model\Order::ENTITY, 1, '1000000001'],
98+
[\Magento\Sales\Model\Order::ENTITY, 2, '2000000001'],
99+
[\Magento\Sales\Model\Order::ENTITY, 3, '3000000001']
100+
];
101+
}
102+
}

app/code/Magento/Sales/Model/ResourceModel/EntityAbstract.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,15 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
121121
{
122122
/** @var \Magento\Sales\Model\AbstractModel $object */
123123
if ($object instanceof EntityInterface && $object->getIncrementId() == null) {
124+
$store = $object->getStore();
125+
$storeId = $store->getId();
126+
if ($storeId === null) {
127+
$storeId = $store->getGroup()->getDefaultStoreId();
128+
}
124129
$object->setIncrementId(
125130
$this->sequenceManager->getSequence(
126131
$object->getEntityType(),
127-
$object->getStore()->getGroup()->getDefaultStoreId()
132+
$storeId
128133
)->getNextValue()
129134
);
130135
}

app/code/Magento/Sales/Observer/Backend/SubtractQtyFromQuotesObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function __construct(\Magento\Quote\Model\ResourceModel\Quote $quote)
3131
public function execute(\Magento\Framework\Event\Observer $observer)
3232
{
3333
$product = $observer->getEvent()->getProduct();
34-
$this->_quote->substractProductFromQuotes($product);
34+
$this->_quote->subtractProductFromQuotes($product);
3535
}
3636
}

app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class SubtractQtyFromQuotesObserverTest extends \PHPUnit_Framework_TestCase
1515
protected $_model;
1616

1717
/**
18-
* @var \PHPUnit_Framework_MockObject_MockObject
18+
* @var \Magento\Quote\Model\ResourceModel\Quote|\PHPUnit_Framework_MockObject_MockObject
1919
*/
2020
protected $_quoteMock;
2121

2222
/**
23-
* @var \PHPUnit_Framework_MockObject_MockObject
23+
* @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject
2424
*/
2525
protected $_observerMock;
2626

@@ -54,7 +54,7 @@ public function testSubtractQtyFromQuotes()
5454
false
5555
);
5656
$this->_eventMock->expects($this->once())->method('getProduct')->will($this->returnValue($productMock));
57-
$this->_quoteMock->expects($this->once())->method('substractProductFromQuotes')->with($productMock);
57+
$this->_quoteMock->expects($this->once())->method('subtractProductFromQuotes')->with($productMock);
5858
$this->_model->execute($this->_observerMock);
5959
}
6060
}

app/code/Magento/Wishlist/CustomerData/Wishlist.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
147147
*/
148148
protected function getImageData($product)
149149
{
150+
/*Set variant product if it is configurable product.
151+
It will show variant product image in sidebar instead of configurable product image.*/
152+
$simpleOption = $product->getCustomOption('simple_product');
153+
if ($simpleOption !== null) {
154+
$optionProduct = $simpleOption->getProduct();
155+
$product = $optionProduct;
156+
}
157+
150158
/** @var \Magento\Catalog\Helper\Image $helper */
151159
$helper = $this->imageHelperFactory->create()
152160
->init($product, 'wishlist_sidebar_block');
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
four and 75/100,4.75
2-
four and 5/10,4.50
2+
four and 5/10,4.50
3+

lib/internal/Magento/Framework/App/Language/Dictionary.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ private function readPackCsv($vendor, $package)
193193
foreach ($foundCsvFiles as $foundCsvFile) {
194194
$file = $directoryRead->openFile($foundCsvFile);
195195
while (($row = $file->readCsv()) !== false) {
196-
$result[$row[0]] = $row[1];
196+
if (is_array($row) && count($row) > 1) {
197+
$result[$row[0]] = $row[1];
198+
}
197199
}
198200
}
199201
}

0 commit comments

Comments
 (0)