Skip to content

Commit 4ce92bd

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-89315
2 parents 9386715 + 94ccd58 commit 4ce92bd

File tree

75 files changed

+8806
-1876
lines changed

Some content is hidden

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

75 files changed

+8806
-1876
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ public function getPopupTitle()
7777
$messageCount = count($this->_messages->getUnread());
7878
if ($messageCount > 1) {
7979
return __('You have %1 new system messages', $messageCount);
80-
} else {
81-
return __('You have %1 new system message', $messageCount);
8280
}
81+
return __('You have %1 new system message', $messageCount);
8382
}
8483

8584
/**

app/code/Magento/AdminNotification/Block/Window.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ protected function _getLatestItem()
9898
{
9999
if ($this->_latestItem == null) {
100100
$items = array_values($this->_criticalCollection->getItems());
101+
$this->_latestItem = false;
101102
if (count($items)) {
102103
$this->_latestItem = $items[0];
103-
} else {
104-
$this->_latestItem = false;
105104
}
106105
}
107106
return $this->_latestItem;

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,8 @@ protected function _getCustomerGroupById(
626626
): string {
627627
if ($allGroups !== 0) {
628628
return ImportAdvancedPricing::VALUE_ALL_GROUPS;
629-
} else {
630-
return $this->_groupRepository->getById($groupId)->getCode();
631629
}
630+
return $this->_groupRepository->getById($groupId)->getCode();
632631
}
633632

634633
/**

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,8 @@ protected function deleteProductTierPrices(array $listSku, $table)
482482
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, 0);
483483
return false;
484484
}
485-
} else {
486-
return false;
487485
}
486+
return false;
488487
}
489488

490489
/**

app/code/Magento/Analytics/Model/Config/Backend/Enabled.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ public function afterSave()
6767
try {
6868
if ($this->isValueChanged()) {
6969
$enabled = $this->getData('value');
70-
71-
if ($enabled) {
72-
$this->subscriptionHandler->processEnabled();
73-
} else {
74-
$this->subscriptionHandler->processDisabled();
75-
}
70+
$enabled ? $this->subscriptionHandler->processEnabled() : $this->subscriptionHandler->processDisabled();
7671
}
7772
} catch (\Exception $e) {
7873
$this->_logger->error($e->getMessage());

app/code/Magento/Authorization/Model/ResourceModel/Role.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
6868
}
6969

7070
if (!$role->getTreeLevel()) {
71+
$treeLevel = 0;
7172
if ($role->getPid() > 0) {
7273
$select = $this->getConnection()->select()->from(
7374
$this->getMainTable(),
@@ -79,8 +80,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
7980
$binds = ['pid' => (int)$role->getPid()];
8081

8182
$treeLevel = $this->getConnection()->fetchOne($select, $binds);
82-
} else {
83-
$treeLevel = 0;
8483
}
8584

8685
$role->setTreeLevel($treeLevel + 1);

app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
2626
*/
2727
protected $_selectionsAppended = false;
2828

29-
/**
30-
* @var int[]
31-
*/
32-
private $productIds = [];
33-
3429
/**
3530
* Init model and resource model
3631
*
@@ -99,34 +94,20 @@ public function joinValues($storeId)
9994
*/
10095
public function setProductIdFilter($productId)
10196
{
102-
$this->productIds[] = $productId;
103-
10497
$productTable = $this->getTable('catalog_product_entity');
10598
$linkField = $this->getConnection()->getAutoIncrementField($productTable);
10699
$this->getSelect()->join(
107100
['cpe' => $productTable],
108101
'cpe.'.$linkField.' = main_table.parent_id',
109102
[]
110103
)->where(
111-
"cpe.entity_id = (?)",
112-
$this->productIds
104+
"cpe.entity_id = ?",
105+
$productId
113106
);
114107

115108
return $this;
116109
}
117110

118-
/**
119-
* Clear product id's after load to insure valid future usage of collection.
120-
*
121-
* @return $this
122-
*/
123-
protected function _afterLoad()
124-
{
125-
$this->productIds = [];
126-
127-
return parent::_afterLoad();
128-
}
129-
130111
/**
131112
* Set product link filter
132113
*

app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,17 @@ private function fetch() : array
9999
$optionsCollection = $this->bundleOptionFactory->create()->getResourceCollection();
100100
// All products in collection will have same store id.
101101
$optionsCollection->joinValues($this->storeManager->getStore()->getId());
102-
foreach ($this->skuMap as $parentInfo) {
103-
$optionsCollection->setProductIdFilter($parentInfo['entity_id']);
104-
}
102+
103+
$productTable = $optionsCollection->getTable('catalog_product_entity');
104+
$linkField = $optionsCollection->getConnection()->getAutoIncrementField($productTable);
105+
$optionsCollection->getSelect()->join(
106+
['cpe' => $productTable],
107+
'cpe.'.$linkField.' = main_table.parent_id',
108+
[]
109+
)->where(
110+
"cpe.entity_id IN (?)",
111+
$this->skuMap
112+
);
105113
$optionsCollection->setPositionOrder();
106114

107115
$this->extensionAttributesJoinProcessor->process($optionsCollection);

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider;
99

1010
use Magento\Catalog\Model\Product\Visibility;
11-
use Magento\Catalog\Model\ResourceModel\CategoryProduct;
12-
use Magento\Framework\Api\SearchCriteriaBuilder;
1311
use Magento\Framework\Api\SearchCriteriaInterface;
1412
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
15-
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
16-
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
1713
use Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory;
1814
use Magento\Framework\Api\SearchResultsInterface;
15+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessorInterface;
1916

2017
/**
2118
* Product field data provider, used for GraphQL resolver processing.
@@ -27,40 +24,15 @@ class Product
2724
*/
2825
private $collectionFactory;
2926

30-
/**
31-
* @var JoinProcessorInterface
32-
*/
33-
private $joinProcessor;
34-
35-
/**
36-
* @var CollectionProcessorInterface
37-
*/
38-
private $collectionProcessor;
39-
4027
/**
4128
* @var ProductSearchResultsInterfaceFactory
4229
*/
4330
private $searchResultsFactory;
4431

4532
/**
46-
* @var CategoryProduct
47-
*/
48-
private $categoryProduct;
49-
50-
/**
51-
* @var SearchCriteriaBuilder
52-
*/
53-
private $searchCriteriaBuilder;
54-
55-
/**
56-
* @var \Magento\Catalog\Model\Layer\Resolver
57-
*/
58-
private $layerResolver;
59-
60-
/**
61-
* @var \Magento\Catalog\Model\ProductRepository
33+
* @var CollectionProcessorInterface
6234
*/
63-
private $productRepository;
35+
private $collectionProcessor;
6436

6537
/**
6638
* @var Visibility
@@ -69,32 +41,20 @@ class Product
6941

7042
/**
7143
* @param CollectionFactory $collectionFactory
72-
* @param JoinProcessorInterface $joinProcessor
73-
* @param CollectionProcessorInterface $collectionProcessor
7444
* @param ProductSearchResultsInterfaceFactory $searchResultsFactory
75-
* @param CategoryProduct $categoryProduct
76-
* @param SearchCriteriaBuilder $searchCriteriaBuilder
45+
* @param Visibility $visibility
46+
* @param CollectionProcessorInterface $collectionProcessor
7747
*/
7848
public function __construct(
7949
CollectionFactory $collectionFactory,
80-
JoinProcessorInterface $joinProcessor,
81-
CollectionProcessorInterface $collectionProcessor,
8250
ProductSearchResultsInterfaceFactory $searchResultsFactory,
83-
CategoryProduct $categoryProduct,
84-
SearchCriteriaBuilder $searchCriteriaBuilder,
85-
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
86-
\Magento\Catalog\Model\ProductRepository $productRepository,
87-
Visibility $visibility
51+
Visibility $visibility,
52+
CollectionProcessorInterface $collectionProcessor
8853
) {
8954
$this->collectionFactory = $collectionFactory;
90-
$this->joinProcessor = $joinProcessor;
91-
$this->collectionProcessor = $collectionProcessor;
9255
$this->searchResultsFactory = $searchResultsFactory;
93-
$this->categoryProduct = $categoryProduct;
94-
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
9556
$this->visibility = $visibility;
96-
$this->layerResolver = $layerResolver;
97-
$this->productRepository = $productRepository;
57+
$this->collectionProcessor = $collectionProcessor;
9858
}
9959

10060
/**
@@ -114,29 +74,17 @@ public function getList(
11474
): SearchResultsInterface {
11575
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
11676
$collection = $this->collectionFactory->create();
117-
$this->joinProcessor->process($collection);
11877

119-
foreach ($attributes as $attributeCode) {
120-
$collection->addAttributeToSelect($attributeCode);
121-
}
122-
$collection->addAttributeToSelect('special_price');
123-
$collection->addAttributeToSelect('special_price_from');
124-
$collection->addAttributeToSelect('special_price_to');
125-
$collection->addAttributeToSelect('tax_class_id');
126-
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
127-
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
78+
$this->collectionProcessor->process($collection, $searchCriteria, $attributes);
12879

12980
if (!$isChildSearch) {
13081
$visibilityIds
13182
= $isSearch ? $this->visibility->getVisibleInSearchIds() : $this->visibility->getVisibleInCatalogIds();
13283
$collection->setVisibility($visibilityIds);
13384
}
134-
135-
$this->collectionProcessor->process($searchCriteria, $collection);
136-
$collection->addWebsiteNamesToResult();
13785
$collection->load();
13886

139-
// Methods that perform extra fetches
87+
// Methods that perform extra fetches post-load
14088
$collection->addCategoryIds();
14189
$collection->addMediaGalleryData();
14290
$collection->addOptionsToResult();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessorInterface;
12+
use Magento\Framework\Api\SearchCriteriaInterface;
13+
14+
/**
15+
* Adds passed in attributes to product collection results
16+
*
17+
* {@inheritdoc}
18+
*/
19+
class AttributeProcessor implements CollectionProcessorInterface
20+
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function process(
25+
Collection $collection,
26+
SearchCriteriaInterface $searchCriteria,
27+
array $attributeNames
28+
): Collection {
29+
foreach ($attributeNames as $name) {
30+
$collection->addAttributeToSelect($name);
31+
}
32+
33+
return $collection;
34+
}
35+
}

0 commit comments

Comments
 (0)