Skip to content

Commit 6e0291d

Browse files
committed
Merge branch '2.3.3-develop' of https://github.com/magento/magento2ce into MC-19051
2 parents a6225f2 + 12e9506 commit 6e0291d

File tree

13 files changed

+248
-187
lines changed

13 files changed

+248
-187
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ protected function _updateRelationProducts($storeId, $productIds = null)
254254
*
255255
* @param int $storeId
256256
* @return \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction
257+
*
258+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
257259
*/
258260
protected function _cleanRelationProducts($storeId)
259261
{
260-
if (!$this->_productIndexerHelper->isAddChildData()) {
262+
if (!$this->_productIndexerHelper->isAddChildData() || !$this->_isFlatTableExists($storeId)) {
261263
return $this;
262264
}
263265

app/code/Magento/Catalog/Model/ProductLink/Search.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function prepareCollection(
6060
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
6161
$productCollection = $this->productCollectionFactory->create();
6262
$productCollection->addAttributeToSelect(ProductInterface::NAME);
63+
$productCollection->setVisibility($this->catalogVisibility->getVisibleInCatalogIds());
6364
$productCollection->setPage($pageNum, $limit);
6465
$this->filter->addFilter($productCollection, 'fulltext', ['fulltext' => $searchKey]);
6566
$productCollection->setPage($pageNum, $limit);

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
230230
{
231231
$connection = $this->getConnection();
232232
$qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0);
233+
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
234+
$linkField = $metadata->getLinkField();
233235

234236
$select = $connection->select()->from(
235237
['e' => $this->getTable('catalog_product_entity')],
@@ -243,6 +245,12 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
243245
['cisi' => $this->getTable('cataloginventory_stock_item')],
244246
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
245247
[]
248+
)->joinInner(
249+
['mcpei' => $this->getTable('catalog_product_entity_int')],
250+
'e.' . $linkField . ' = mcpei.' . $linkField
251+
. ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId()
252+
. ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED,
253+
[]
246254
)->columns(
247255
['qty' => $qtyExpr]
248256
)->where(
@@ -284,7 +292,6 @@ protected function _prepareIndexTable($entityIds = null)
284292
*/
285293
protected function _updateIndex($entityIds)
286294
{
287-
$this->deleteOldRecords($entityIds);
288295
$connection = $this->getConnection();
289296
$select = $this->_getStockStatusSelect($entityIds, true);
290297
$select = $this->getQueryProcessorComposite()->processQuery($select, $entityIds, true);
@@ -307,6 +314,7 @@ protected function _updateIndex($entityIds)
307314
}
308315
}
309316

317+
$this->deleteOldRecords($entityIds);
310318
$this->_updateIndexTable($data);
311319

312320
return $this;

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\App\ProductMetadataInterface;
1212
use Magento\Framework\Async\CallbackDeferred;
13-
use Magento\Framework\Async\ProxyDeferredFactory;
1413
use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface;
1514
use Magento\Framework\HTTP\AsyncClient\Request;
1615
use Magento\Framework\HTTP\AsyncClientInterface;
@@ -21,6 +20,7 @@
2120
use Magento\Quote\Model\Quote\Address\RateResult\Error;
2221
use Magento\Shipping\Model\Carrier\AbstractCarrier;
2322
use Magento\Shipping\Model\Rate\Result;
23+
use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory;
2424
use Magento\Framework\Xml\Security;
2525
use Magento\Dhl\Model\Validator\XmlValidator;
2626

@@ -389,16 +389,17 @@ public function collectRates(RateRequest $request)
389389
//Saving $result to use proper result with the callback
390390
$this->_result = $result = $this->_getQuotes();
391391
//After quotes are loaded parsing the response.
392-
return $this->proxyDeferredFactory->createFor(
393-
Result::class,
394-
new CallbackDeferred(
395-
function () use ($request, $result) {
396-
$this->_result = $result;
397-
$this->_updateFreeMethodQuote($request);
398-
399-
return $this->_result;
400-
}
401-
)
392+
return $this->proxyDeferredFactory->create(
393+
[
394+
'deferred' => new CallbackDeferred(
395+
function () use ($request, $result) {
396+
$this->_result = $result;
397+
$this->_updateFreeMethodQuote($request);
398+
399+
return $this->_result;
400+
}
401+
)
402+
]
402403
);
403404
}
404405

@@ -818,16 +819,16 @@ protected function _getAllItems()
818819

819820
if (!empty($decimalItems)) {
820821
foreach ($decimalItems as $decimalItem) {
821-
$fullItems = array_merge(
822-
$fullItems,
823-
array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight'])
824-
);
822+
$fullItems[] = array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']);
825823
}
826824
} else {
827-
$fullItems = array_merge($fullItems, array_fill(0, $qty, $this->_getWeight($itemWeight)));
825+
$fullItems[] = array_fill(0, $qty, $this->_getWeight($itemWeight));
828826
}
829827
}
830-
sort($fullItems);
828+
if ($fullItems) {
829+
$fullItems = array_merge(...$fullItems);
830+
sort($fullItems);
831+
}
831832

832833
return $fullItems;
833834
}
@@ -1057,23 +1058,24 @@ protected function _getQuotes()
10571058
}
10581059
}
10591060

1060-
return $this->proxyDeferredFactory->createFor(
1061-
Result::class,
1062-
new CallbackDeferred(
1063-
function () use ($deferredResponses, $responseBodies) {
1064-
//Loading rates not found in cache
1065-
foreach ($deferredResponses as $deferredResponseData) {
1066-
$responseBodies[] = [
1067-
'body' => $deferredResponseData['deferred']->get()->getBody(),
1068-
'date' => $deferredResponseData['date'],
1069-
'request' => $deferredResponseData['request'],
1070-
'from_cache' => false
1071-
];
1072-
}
1061+
return $this->proxyDeferredFactory->create(
1062+
[
1063+
'deferred' => new CallbackDeferred(
1064+
function () use ($deferredResponses, $responseBodies) {
1065+
//Loading rates not found in cache
1066+
foreach ($deferredResponses as $deferredResponseData) {
1067+
$responseBodies[] = [
1068+
'body' => $deferredResponseData['deferred']->get()->getBody(),
1069+
'date' => $deferredResponseData['date'],
1070+
'request' => $deferredResponseData['request'],
1071+
'from_cache' => false
1072+
];
1073+
}
10731074

1074-
return $this->processQuotesResponses($responseBodies);
1075-
}
1076-
)
1075+
return $this->processQuotesResponses($responseBodies);
1076+
}
1077+
)
1078+
]
10771079
);
10781080
}
10791081

app/code/Magento/Store/Model/ScopeTreeProvider.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Store\Model;
79

810
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -78,25 +80,30 @@ public function get()
7880
'scopes' => [],
7981
];
8082

81-
/** @var Group $group */
82-
foreach ($groups[$website->getId()] as $group) {
83-
$groupScope = [
84-
'scope' => ScopeInterface::SCOPE_GROUP,
85-
'scope_id' => $group->getId(),
86-
'scopes' => [],
87-
];
88-
89-
/** @var Store $store */
90-
foreach ($stores[$group->getId()] as $store) {
91-
$storeScope = [
92-
'scope' => ScopeInterface::SCOPE_STORES,
93-
'scope_id' => $store->getId(),
83+
if (!empty($groups[$website->getId()])) {
84+
/** @var Group $group */
85+
foreach ($groups[$website->getId()] as $group) {
86+
$groupScope = [
87+
'scope' => ScopeInterface::SCOPE_GROUP,
88+
'scope_id' => $group->getId(),
9489
'scopes' => [],
9590
];
96-
$groupScope['scopes'][] = $storeScope;
91+
92+
if (!empty($stores[$group->getId()])) {
93+
/** @var Store $store */
94+
foreach ($stores[$group->getId()] as $store) {
95+
$storeScope = [
96+
'scope' => ScopeInterface::SCOPE_STORES,
97+
'scope_id' => $store->getId(),
98+
'scopes' => [],
99+
];
100+
$groupScope['scopes'][] = $storeScope;
101+
}
102+
}
103+
$websiteScope['scopes'][] = $groupScope;
97104
}
98-
$websiteScope['scopes'][] = $groupScope;
99105
}
106+
100107
$defaultScope['scopes'][] = $websiteScope;
101108
}
102109

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Async\CallbackDeferred;
12-
use Magento\Framework\Async\ProxyDeferredFactory;
1312
use Magento\Framework\DataObject;
1413
use Magento\Framework\Exception\LocalizedException;
1514
use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface;
@@ -22,6 +21,7 @@
2221
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
2322
use Magento\Shipping\Model\Carrier\CarrierInterface;
2423
use Magento\Shipping\Model\Rate\Result;
24+
use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory;
2525
use Magento\Shipping\Model\Simplexml\Element;
2626
use Magento\Ups\Helper\Config;
2727
use Magento\Shipping\Model\Shipment\Request as Shipment;
@@ -239,15 +239,16 @@ public function collectRates(RateRequest $request)
239239
//To use the correct result in the callback.
240240
$this->_result = $result = $this->_getQuotes();
241241

242-
return $this->deferredProxyFactory->createFor(
243-
Result::class,
244-
new CallbackDeferred(
245-
function () use ($request, $result) {
246-
$this->_result = $result;
247-
$this->_updateFreeMethodQuote($request);
248-
return $this->getResult();
249-
}
250-
)
242+
return $this->deferredProxyFactory->create(
243+
[
244+
'deferred' => new CallbackDeferred(
245+
function () use ($request, $result) {
246+
$this->_result = $result;
247+
$this->_updateFreeMethodQuote($request);
248+
return $this->getResult();
249+
}
250+
)
251+
]
251252
);
252253
}
253254

@@ -782,19 +783,20 @@ protected function _getXmlQuotes()
782783
new Request($url, Request::METHOD_POST, ['Content-Type' => 'application/xml'], $xmlRequest)
783784
);
784785

785-
return $this->deferredProxyFactory->createFor(
786-
Result::class,
787-
new CallbackDeferred(
788-
function () use ($httpResponse) {
789-
if ($httpResponse->get()->getStatusCode() >= 400) {
790-
$xmlResponse = '';
791-
} else {
792-
$xmlResponse = $httpResponse->get()->getBody();
793-
}
786+
return $this->deferredProxyFactory->create(
787+
[
788+
'deferred' => new CallbackDeferred(
789+
function () use ($httpResponse) {
790+
if ($httpResponse->get()->getStatusCode() >= 400) {
791+
$xmlResponse = '';
792+
} else {
793+
$xmlResponse = $httpResponse->get()->getBody();
794+
}
794795

795-
return $this->_parseXmlResponse($xmlResponse);
796-
}
797-
)
796+
return $this->_parseXmlResponse($xmlResponse);
797+
}
798+
)
799+
]
798800
);
799801
}
800802

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
use Magento\Framework\App\ObjectManager;
1010
use Magento\Framework\Async\CallbackDeferred;
11-
use Magento\Framework\Async\ProxyDeferredFactory;
1211
use Magento\Framework\HTTP\AsyncClient\Request;
1312
use Magento\Framework\HTTP\AsyncClientInterface;
1413
use Magento\Framework\Xml\Security;
1514
use Magento\Quote\Model\Quote\Address\RateRequest;
1615
use Magento\Shipping\Helper\Carrier as CarrierHelper;
1716
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
1817
use Magento\Shipping\Model\Rate\Result;
18+
use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory;
1919
use Magento\Usps\Helper\Data as DataHelper;
2020

2121
/**
@@ -239,16 +239,17 @@ public function collectRates(RateRequest $request)
239239
//Saving current result to use the right one in the callback.
240240
$this->_result = $result = $this->_getQuotes();
241241

242-
return $this->proxyDeferredFactory->createFor(
243-
Result::class,
244-
new CallbackDeferred(
245-
function () use ($request, $result) {
246-
$this->_result = $result;
247-
$this->_updateFreeMethodQuote($request);
242+
return $this->proxyDeferredFactory->create(
243+
[
244+
'deferred' => new CallbackDeferred(
245+
function () use ($request, $result) {
246+
$this->_result = $result;
247+
$this->_updateFreeMethodQuote($request);
248248

249-
return $this->getResult();
250-
}
251-
)
249+
return $this->getResult();
250+
}
251+
)
252+
]
252253
);
253254
}
254255

@@ -555,18 +556,19 @@ protected function _getXmlQuotes()
555556
)
556557
);
557558

558-
return $this->proxyDeferredFactory->createFor(
559-
Result::class,
560-
new CallbackDeferred(
561-
function () use ($deferredResponse, $request, $debugData) {
562-
$responseBody = $deferredResponse->get()->getBody();
563-
$debugData['result'] = $responseBody;
564-
$this->_setCachedQuotes($request, $responseBody);
565-
$this->_debug($debugData);
566-
567-
return $this->_parseXmlResponse($responseBody);
568-
}
569-
)
559+
return $this->proxyDeferredFactory->create(
560+
[
561+
'deferred' => new CallbackDeferred(
562+
function () use ($deferredResponse, $request, $debugData) {
563+
$responseBody = $deferredResponse->get()->getBody();
564+
$debugData['result'] = $responseBody;
565+
$this->_setCachedQuotes($request, $responseBody);
566+
$this->_debug($debugData);
567+
568+
return $this->_parseXmlResponse($responseBody);
569+
}
570+
)
571+
]
570572
);
571573
}
572574

0 commit comments

Comments
 (0)