Skip to content

Commit 548ef66

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #13933: Configurable product price options by store (by @simpleadm) - #14496: [forwardport] fix for button color in email template (by @Karlasa) - #13394: #12705: Integrity constraint violation error after re� (by @vinayshah) - #14461: [Forwardport] precision for price overriding by js (by @mastiuhin-olexandr) - #14540: Align else statements at app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php (by @nuzil) - #14536: [Forwardport] Check if store id is not null instead of empty (by @mastiuhin-olexandr) - #14532: [Forwardport] [Bug] Correctly construct Magento\Framework\Phrase (by @mastiuhin-olexandr) - #14528: [Forwardport] Fix issue #13010. Check if product is assigned to current website. (by @mastiuhin-olexandr) - #14525: [forwardport] fix translation issue with rating stars (by @Karlasa) - #14508: [Forwardport] Issue #13582 show message for qty minAllowed, maxAllowed, qtyIncremen� (by @mastiuhin-olexandr) - #14502: [Forwardport] Check if store id is not null instead of empty (by @quisse) - #14438: Remove json helper data usage in AdminNotification (by @dmanners) - #14169: Add json and xml support to the post method in socket client (by @simpleadm) Fixed GitHub Issues: - #12705: Integrity constraint violation error after reordering product with custom options (reported by @alena-marchenko) has been fixed in #13394 by @vinayshah in 2.3-develop branch Related commits: 1. b5b4530 - #14249: Priduct page price is using the hardcoded digits in js (reported by @cdiacon) has been fixed in #14461 by @mastiuhin-olexandr in 2.3-develop branch Related commits: 1. bbf8b9c - #13010: Write a Review page works on multistore for products that are not assigned to that store (reported by @nuethicadam) has been fixed in #14528 by @mastiuhin-olexandr in 2.3-develop branch Related commits: 1. 189f36d - #13582: Magento 2.1.11 minimum quantity validation message not showing (reported by @jayanta88) has been fixed in #14508 by @mastiuhin-olexandr in 2.3-develop branch Related commits: 1. a2c1a64 2. 2596ad5 3. 2be7da9 4. eae1c03 - #9236: Upgrade ZF components. Zend_Json (reported by @okorshenko) has been fixed in #14438 by @dmanners in 2.3-develop branch Related commits: 1. cdca73b 2. 6561541 - #3489: CURL Json POST (reported by @Grohotun) has been fixed in #14169 by @simpleadm in 2.3-develop branch Related commits: 1. 03bbca6
2 parents c804fc0 + 54c141d commit 548ef66

File tree

18 files changed

+182
-39
lines changed

18 files changed

+182
-39
lines changed

app/code/Magento/AdminNotification/Block/System/Messages.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,34 @@ class Messages extends \Magento\Backend\Block\Template
1616

1717
/**
1818
* @var \Magento\Framework\Json\Helper\Data
19+
* @deprecated
1920
*/
2021
protected $jsonHelper;
2122

23+
/**
24+
* @var \Magento\Framework\Serialize\Serializer\Json
25+
*/
26+
private $serializer;
27+
2228
/**
2329
* @param \Magento\Backend\Block\Template\Context $context
2430
* @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages
2531
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
2632
* @param array $data
33+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
2734
*/
2835
public function __construct(
2936
\Magento\Backend\Block\Template\Context $context,
3037
\Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages,
3138
\Magento\Framework\Json\Helper\Data $jsonHelper,
32-
array $data = []
39+
array $data = [],
40+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
3341
) {
3442
$this->jsonHelper = $jsonHelper;
3543
parent::__construct($context, $data);
3644
$this->_messages = $messages;
45+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3747
}
3848

3949
/**
@@ -117,7 +127,7 @@ protected function _getMessagesUrl()
117127
*/
118128
public function getSystemMessageDialogJson()
119129
{
120-
return $this->jsonHelper->jsonEncode(
130+
return $this->serializer->serialize(
121131
[
122132
'systemMessageDialog' => [
123133
'buttons' => [],

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\AdminNotification\Controller\Adminhtml\System\Message;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class ListAction extends \Magento\Backend\App\AbstractAction
1012
{
1113
/**
@@ -15,6 +17,7 @@ class ListAction extends \Magento\Backend\App\AbstractAction
1517

1618
/**
1719
* @var \Magento\Framework\Json\Helper\Data
20+
* @deprecated
1821
*/
1922
protected $jsonHelper;
2023

@@ -41,7 +44,7 @@ public function __construct(
4144
}
4245

4346
/**
44-
* @return void
47+
* @return \Magento\Framework\Controller\Result\Json
4548
*/
4649
public function execute()
4750
{
@@ -63,6 +66,9 @@ public function execute()
6366
. 'Please refresh the web page to clear the notice alert.',
6467
];
6568
}
66-
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
69+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
70+
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
71+
$resultJson->setData($result);
72+
return $resultJson;
6773
}
6874
}

app/code/Magento/Catalog/view/base/web/js/price-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ define([
7979
am = Number(Math.round(Math.abs(amount - i) + 'e+' + precision) + ('e-' + precision));
8080
r = (j ? i.substr(0, j) + groupSymbol : '') +
8181
i.substr(j).replace(re, '$1' + groupSymbol) +
82-
(precision ? decimalSymbol + am.toFixed(2).replace(/-/, 0).slice(2) : '');
82+
(precision ? decimalSymbol + am.toFixed(precision).replace(/-/, 0).slice(2) : '');
8383

8484
return pattern.replace('%s', r).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
8585
}

app/code/Magento/CatalogInventory/Block/Plugin/ProductView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function afterGetQuantityValidators(
3939

4040
$params = [];
4141
$params['minAllowed'] = (float)$stockItem->getMinSaleQty();
42-
if ($stockItem->getQtyMaxAllowed()) {
43-
$params['maxAllowed'] = $stockItem->getQtyMaxAllowed();
42+
if ($stockItem->getMaxSaleQty()) {
43+
$params['maxAllowed'] = (float)$stockItem->getMaxSaleQty();
4444
}
4545
if ($stockItem->getQtyIncrements() > 0) {
4646
$params['qtyIncrements'] = (float)$stockItem->getQtyIncrements();

app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function setUp()
2828

2929
$this->stockItem = $this->getMockBuilder(\Magento\CatalogInventory\Model\Stock\Item::class)
3030
->disableOriginalConstructor()
31-
->setMethods(['getMinSaleQty', 'getQtyMaxAllowed', 'getQtyIncrements'])
31+
->setMethods(['getMinSaleQty', 'getMaxSaleQty', 'getQtyIncrements'])
3232
->getMock();
3333

3434
$this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class)
@@ -48,8 +48,8 @@ public function testAfterGetQuantityValidators()
4848
'validate-item-quantity' =>
4949
[
5050
'minAllowed' => 0.5,
51-
'maxAllowed' => 5,
52-
'qtyIncrements' => 3
51+
'maxAllowed' => 5.0,
52+
'qtyIncrements' => 3.0
5353
]
5454
];
5555
$validators = [];
@@ -74,7 +74,7 @@ public function testAfterGetQuantityValidators()
7474
->with('productId', 'websiteId')
7575
->willReturn($this->stockItem);
7676
$this->stockItem->expects($this->once())->method('getMinSaleQty')->willReturn(0.5);
77-
$this->stockItem->expects($this->any())->method('getQtyMaxAllowed')->willReturn(5);
77+
$this->stockItem->expects($this->any())->method('getMaxSaleQty')->willReturn(5);
7878
$this->stockItem->expects($this->any())->method('getQtyIncrements')->willReturn(3);
7979

8080
$this->assertEquals($result, $this->block->afterGetQuantityValidators($productViewBlock, $validators));

app/code/Magento/Cms/Model/PageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function __construct(
111111
*/
112112
public function save(\Magento\Cms\Api\Data\PageInterface $page)
113113
{
114-
if (empty($page->getStoreId())) {
114+
if ($page->getStoreId() === null) {
115115
$storeId = $this->storeManager->getStore()->getId();
116116
$page->setStoreId($storeId);
117117
}

app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ protected function _getSuperAttributeId($productId, $attributeId)
247247
{
248248
if (isset($this->_productSuperAttrs["{$productId}_{$attributeId}"])) {
249249
return $this->_productSuperAttrs["{$productId}_{$attributeId}"];
250-
} else {
251-
return null;
252250
}
251+
return null;
253252
}
254253

255254
/**

app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProvider.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
1010
use Magento\Framework\App\ResourceConnection;
1111
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
12+
use Magento\Store\Model\StoreManagerInterface;
1213

1314
/**
1415
* Retrieve list of products where each product contains lower price than others at least for one possible price type
@@ -31,7 +32,12 @@ class LowestPriceOptionsProvider implements LowestPriceOptionsProviderInterface
3132
private $collectionFactory;
3233

3334
/**
34-
* Key is product id. Value is array of prepared linked products
35+
* @var StoreManagerInterface
36+
*/
37+
private $storeManager;
38+
39+
/**
40+
* Key is product id and store id. Value is array of prepared linked products
3541
*
3642
* @var array
3743
*/
@@ -41,34 +47,38 @@ class LowestPriceOptionsProvider implements LowestPriceOptionsProviderInterface
4147
* @param ResourceConnection $resourceConnection
4248
* @param LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
4349
* @param CollectionFactory $collectionFactory
50+
* @param StoreManagerInterface $storeManager
4451
*/
4552
public function __construct(
4653
ResourceConnection $resourceConnection,
4754
LinkedProductSelectBuilderInterface $linkedProductSelectBuilder,
48-
CollectionFactory $collectionFactory
55+
CollectionFactory $collectionFactory,
56+
StoreManagerInterface $storeManager
4957
) {
5058
$this->resource = $resourceConnection;
5159
$this->linkedProductSelectBuilder = $linkedProductSelectBuilder;
5260
$this->collectionFactory = $collectionFactory;
61+
$this->storeManager = $storeManager;
5362
}
5463

5564
/**
5665
* {@inheritdoc}
5766
*/
5867
public function getProducts(ProductInterface $product)
5968
{
60-
if (!isset($this->linkedProductMap[$product->getId()])) {
69+
$key = $this->storeManager->getStore()->getId() . '-' . $product->getId();
70+
if (!isset($this->linkedProductMap[$key])) {
6171
$productIds = $this->resource->getConnection()->fetchCol(
6272
'(' . implode(') UNION (', $this->linkedProductSelectBuilder->build($product->getId())) . ')'
6373
);
6474

65-
$this->linkedProductMap[$product->getId()] = $this->collectionFactory->create()
75+
$this->linkedProductMap[$key] = $this->collectionFactory->create()
6676
->addAttributeToSelect(
6777
['price', 'special_price', 'special_from_date', 'special_to_date', 'tax_class_id']
6878
)
6979
->addIdFilter($productIds)
7080
->getItems();
7181
}
72-
return $this->linkedProductMap[$product->getId()];
82+
return $this->linkedProductMap[$key];
7383
}
7484
}

app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Store\Api\Data\StoreInterface;
14+
use Magento\Store\Model\Store;
1215

1316
class LowestPriceOptionsProviderTest extends \PHPUnit\Framework\TestCase
1417
{
@@ -42,6 +45,16 @@ class LowestPriceOptionsProviderTest extends \PHPUnit\Framework\TestCase
4245
*/
4346
private $productCollection;
4447

48+
/**
49+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
50+
*/
51+
private $storeManagerMock;
52+
53+
/**
54+
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $storeMock;
57+
4558
protected function setUp()
4659
{
4760
$this->connection = $this
@@ -68,6 +81,11 @@ protected function setUp()
6881
->setMethods(['create'])
6982
->getMock();
7083
$this->collectionFactory->expects($this->once())->method('create')->willReturn($this->productCollection);
84+
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
85+
->getMockForAbstractClass();
86+
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
87+
->setMethods(['getId'])
88+
->getMockForAbstractClass();
7189

7290
$objectManager = new ObjectManager($this);
7391
$this->model = $objectManager->getObject(
@@ -76,6 +94,7 @@ protected function setUp()
7694
'resourceConnection' => $this->resourceConnection,
7795
'linkedProductSelectBuilder' => $this->linkedProductSelectBuilder,
7896
'collectionFactory' => $this->collectionFactory,
97+
'storeManager' => $this->storeManagerMock,
7998
]
8099
);
81100
}
@@ -94,6 +113,13 @@ public function testGetProducts()
94113
->willReturnSelf();
95114
$this->productCollection->expects($this->once())->method('addIdFilter')->willReturnSelf();
96115
$this->productCollection->expects($this->once())->method('getItems')->willReturn($linkedProducts);
116+
$this->storeManagerMock->expects($this->any())
117+
->method('getStore')
118+
->with(Store::DEFAULT_STORE_ID)
119+
->willReturn($this->storeMock);
120+
$this->storeMock->expects($this->any())
121+
->method('getId')
122+
->willReturn(Store::DEFAULT_STORE_ID);
97123

98124
$this->assertEquals($linkedProducts, $this->model->getProducts($product));
99125
}

app/code/Magento/Review/Controller/Product.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ protected function loadProduct($productId)
219219

220220
try {
221221
$product = $this->productRepository->getById($productId);
222+
223+
if (!in_array($this->storeManager->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
224+
throw new NoSuchEntityException();
225+
}
226+
222227
if (!$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
223228
throw new NoSuchEntityException();
224229
}

0 commit comments

Comments
 (0)