Skip to content

Commit c433d4b

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into libs-upgrade
# Conflicts: # .travis.yml # composer.lock
2 parents afdb6a9 + 452710d commit c433d4b

File tree

141 files changed

+2633
-901
lines changed

Some content is hidden

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

141 files changed

+2633
-901
lines changed

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ public function execute()
2828
)->markAsRead(
2929
$notificationId
3030
);
31-
$this->messageManager->addSuccess(__('The message has been marked as Read.'));
31+
$this->messageManager->addSuccessMessage(__('The message has been marked as Read.'));
3232
} catch (\Magento\Framework\Exception\LocalizedException $e) {
33-
$this->messageManager->addError($e->getMessage());
33+
$this->messageManager->addErrorMessage($e->getMessage());
3434
} catch (\Exception $e) {
35-
$this->messageManager->addException(
35+
$this->messageManager->addExceptionMessage(
3636
$e,
3737
__("We couldn't mark the notification as Read because of an error.")
3838
);

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function execute()
2323
{
2424
$ids = $this->getRequest()->getParam('notification');
2525
if (!is_array($ids)) {
26-
$this->messageManager->addError(__('Please select messages.'));
26+
$this->messageManager->addErrorMessage(__('Please select messages.'));
2727
} else {
2828
try {
2929
foreach ($ids as $id) {
@@ -32,13 +32,13 @@ public function execute()
3232
$model->setIsRead(1)->save();
3333
}
3434
}
35-
$this->messageManager->addSuccess(
35+
$this->messageManager->addSuccessMessage(
3636
__('A total of %1 record(s) have been marked as Read.', count($ids))
3737
);
3838
} catch (\Magento\Framework\Exception\LocalizedException $e) {
39-
$this->messageManager->addError($e->getMessage());
39+
$this->messageManager->addErrorMessage($e->getMessage());
4040
} catch (\Exception $e) {
41-
$this->messageManager->addException(
41+
$this->messageManager->addExceptionMessage(
4242
$e,
4343
__("We couldn't mark the notification as Read because of an error.")
4444
);

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function execute()
2323
{
2424
$ids = $this->getRequest()->getParam('notification');
2525
if (!is_array($ids)) {
26-
$this->messageManager->addError(__('Please select messages.'));
26+
$this->messageManager->addErrorMessage(__('Please select messages.'));
2727
} else {
2828
try {
2929
foreach ($ids as $id) {
@@ -32,11 +32,14 @@ public function execute()
3232
$model->setIsRemove(1)->save();
3333
}
3434
}
35-
$this->messageManager->addSuccess(__('Total of %1 record(s) have been removed.', count($ids)));
35+
$this->messageManager->addSuccessMessage(__('Total of %1 record(s) have been removed.', count($ids)));
3636
} catch (\Magento\Framework\Exception\LocalizedException $e) {
37-
$this->messageManager->addError($e->getMessage());
37+
$this->messageManager->addErrorMessage($e->getMessage());
3838
} catch (\Exception $e) {
39-
$this->messageManager->addException($e, __("We couldn't remove the messages because of an error."));
39+
$this->messageManager->addExceptionMessage(
40+
$e,
41+
__("We couldn't remove the messages because of an error.")
42+
);
4043
}
4144
}
4245
$this->_redirect('adminhtml/*/');

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ public function execute()
3131

3232
try {
3333
$model->setIsRemove(1)->save();
34-
$this->messageManager->addSuccess(__('The message has been removed.'));
34+
$this->messageManager->addSuccessMessage(__('The message has been removed.'));
3535
} catch (\Magento\Framework\Exception\LocalizedException $e) {
36-
$this->messageManager->addError($e->getMessage());
36+
$this->messageManager->addErrorMessage($e->getMessage());
3737
} catch (\Exception $e) {
38-
$this->messageManager->addException($e, __("We couldn't remove the messages because of an error."));
38+
$this->messageManager->addExceptionMessage(
39+
$e,
40+
__("We couldn't remove the messages because of an error.")
41+
);
3942
}
4043

4144
$this->_redirect('adminhtml/*/');
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Ui\Component\Control;
9+
10+
use Magento\Framework\App\RequestInterface;
11+
use Magento\Framework\Escaper;
12+
use Magento\Framework\UrlInterface;
13+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
14+
15+
/**
16+
* Represents delete button with pre-configured options
17+
* Provide an ability to show confirmation message on click on the "Delete" button
18+
*
19+
* @api
20+
*/
21+
class DeleteButton implements ButtonProviderInterface
22+
{
23+
/**
24+
* @var RequestInterface
25+
*/
26+
private $request;
27+
28+
/**
29+
* @var UrlInterface
30+
*/
31+
private $urlBuilder;
32+
33+
/**
34+
* @var Escaper
35+
*/
36+
private $escaper;
37+
38+
/**
39+
* @var string
40+
*/
41+
private $confirmationMessage;
42+
43+
/**
44+
* @var string
45+
*/
46+
private $idFieldName;
47+
48+
/**
49+
* @var string
50+
*/
51+
private $deleteRoutePath;
52+
53+
/**
54+
* @var int
55+
*/
56+
private $sortOrder;
57+
58+
/**
59+
* @param RequestInterface $request
60+
* @param UrlInterface $urlBuilder
61+
* @param Escaper $escaper
62+
* @param string $confirmationMessage
63+
* @param string $idFieldName
64+
* @param string $deleteRoutePath
65+
* @param int $sortOrder
66+
*/
67+
public function __construct(
68+
RequestInterface $request,
69+
UrlInterface $urlBuilder,
70+
Escaper $escaper,
71+
string $confirmationMessage,
72+
string $idFieldName,
73+
string $deleteRoutePath,
74+
int $sortOrder
75+
) {
76+
$this->request = $request;
77+
$this->urlBuilder = $urlBuilder;
78+
$this->escaper = $escaper;
79+
$this->confirmationMessage = $confirmationMessage;
80+
$this->idFieldName = $idFieldName;
81+
$this->deleteRoutePath = $deleteRoutePath;
82+
$this->sortOrder = $sortOrder;
83+
}
84+
85+
/**
86+
* {@inheritdoc}
87+
*/
88+
public function getButtonData()
89+
{
90+
$data = [];
91+
$fieldId = $this->escaper->escapeJs($this->escaper->escapeHtml($this->request->getParam($this->idFieldName)));
92+
if (null !== $fieldId) {
93+
$url = $this->urlBuilder->getUrl($this->deleteRoutePath);
94+
$escapedMessage = $this->escaper->escapeJs($this->escaper->escapeHtml($this->confirmationMessage));
95+
$data = [
96+
'label' => __('Delete'),
97+
'class' => 'delete',
98+
'on_click' => "deleteConfirm('{$escapedMessage}', '{$url}', {data:{{$this->idFieldName}:{$fieldId}}})",
99+
'sort_order' => $this->sortOrder,
100+
];
101+
}
102+
return $data;
103+
}
104+
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CompositeProductRowSizeEstimator implements IndexTableRowSizeEstimatorInte
1818
/**
1919
* Calculated memory size for one record in catalog_product_index_price table
2020
*/
21-
const MEMORY_SIZE_FOR_ONE_ROW = 200;
21+
const MEMORY_SIZE_FOR_ONE_ROW = 250;
2222

2323
/**
2424
* @var WebsiteManagementInterface

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class IndexTableRowSizeEstimator implements \Magento\Framework\Indexer\IndexTabl
1515
/**
1616
* Calculated memory size for one record in catalog_product_index_price table
1717
*/
18-
const MEMORY_SIZE_FOR_ONE_ROW = 120;
18+
const MEMORY_SIZE_FOR_ONE_ROW = 200;
1919

2020
/**
2121
* @var \Magento\Store\Api\WebsiteManagementInterface

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected function setUp()
4949

5050
public function testEstimateRowSize()
5151
{
52+
$this->markTestSkipped('Unskip after MAGETWO-89738');
5253
$expectedResult = 40000000;
5354
$maxRelatedProductCount = 10;
5455

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected function setUp()
3838

3939
public function testEstimateRowSize()
4040
{
41+
$this->markTestSkipped('Unskip after MAGETWO-89738');
4142
$expectedValue = 2400000;
4243

4344
$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\CatalogImportExport\Model\Import\Product\MediaGalleryProcessor;
1111
use Magento\CatalogImportExport\Model\Import\Product\ImageTypeProcessor;
1212
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
13+
use Magento\CatalogImportExport\Model\StockItemImporterInterface;
1314
use Magento\Framework\App\Filesystem\DirectoryList;
1415
use Magento\Framework\App\ObjectManager;
1516
use Magento\Framework\Exception\LocalizedException;
@@ -535,6 +536,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
535536

536537
/**
537538
* @var \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory
539+
* @deprecated this variable isn't used anymore.
538540
*/
539541
protected $_stockResItemFac;
540542

@@ -703,6 +705,13 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
703705
*/
704706
private $catalogConfig;
705707

708+
/**
709+
* Stock Item Importer
710+
*
711+
* @var StockItemImporterInterface
712+
*/
713+
private $stockItemImporter;
714+
706715
/**
707716
* @var ImageTypeProcessor
708717
*/
@@ -751,12 +760,13 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
751760
* @param TransactionManagerInterface $transactionManager
752761
* @param Product\TaxClassProcessor $taxClassProcessor
753762
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
763+
* @param \Magento\Catalog\Model\Product\Url $productUrl
754764
* @param array $data
755765
* @param array $dateAttrCodes
756766
* @param CatalogConfig $catalogConfig
757767
* @param ImageTypeProcessor $imageTypeProcessor
758768
* @param MediaGalleryProcessor $mediaProcessor
759-
* @throws \Magento\Framework\Exception\LocalizedException
769+
* @param StockItemImporterInterface|null $stockItemImporter
760770
*
761771
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
762772
*/
@@ -801,7 +811,8 @@ public function __construct(
801811
array $dateAttrCodes = [],
802812
CatalogConfig $catalogConfig = null,
803813
ImageTypeProcessor $imageTypeProcessor = null,
804-
MediaGalleryProcessor $mediaProcessor = null
814+
MediaGalleryProcessor $mediaProcessor = null,
815+
StockItemImporterInterface $stockItemImporter = null
805816
) {
806817
$this->_eventManager = $eventManager;
807818
$this->stockRegistry = $stockRegistry;
@@ -835,7 +846,8 @@ public function __construct(
835846
$this->catalogConfig = $catalogConfig ?: ObjectManager::getInstance()->get(CatalogConfig::class);
836847
$this->imageTypeProcessor = $imageTypeProcessor ?: ObjectManager::getInstance()->get(ImageTypeProcessor::class);
837848
$this->mediaProcessor = $mediaProcessor ?: ObjectManager::getInstance()->get(MediaGalleryProcessor::class);
838-
849+
$this->stockItemImporter = $stockItemImporter ?: ObjectManager::getInstance()
850+
->get(StockItemImporterInterface::class);
839851
parent::__construct(
840852
$jsonHelper,
841853
$importExportData,
@@ -851,7 +863,6 @@ public function __construct(
851863
) ? $data['option_entity'] : $optionFactory->create(
852864
['data' => ['product_entity' => $this]]
853865
);
854-
855866
$this->_initAttributeSets()
856867
->_initTypeModels()
857868
->_initSkus()
@@ -2128,9 +2139,6 @@ protected function _saveProductWebsites(array $websiteData)
21282139
*/
21292140
protected function _saveStockItem()
21302141
{
2131-
/** @var $stockResource \Magento\CatalogInventory\Model\ResourceModel\Stock\Item */
2132-
$stockResource = $this->_stockResItemFac->create();
2133-
$entityTable = $stockResource->getMainTable();
21342142
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
21352143
$stockData = [];
21362144
$productIdsToReindex = [];
@@ -2158,6 +2166,7 @@ protected function _saveStockItem()
21582166
array_intersect_key($rowData, $this->defaultStockData),
21592167
$row
21602168
);
2169+
$row['sku'] = $sku;
21612170

21622171
if ($this->stockConfiguration->isQty(
21632172
$this->skuProcessor->getNewSku($sku)['type_id']
@@ -2185,7 +2194,7 @@ protected function _saveStockItem()
21852194

21862195
// Insert rows
21872196
if (!empty($stockData)) {
2188-
$this->_connection->insertOnDuplicate($entityTable, array_values($stockData));
2197+
$this->stockItemImporter->import($stockData);
21892198
}
21902199

21912200
$this->reindexProducts($productIdsToReindex);

0 commit comments

Comments
 (0)