Skip to content

Commit 353097e

Browse files
authored
Merge branch '2.4-develop' into 2.4-dev
2 parents 460252f + 1064e35 commit 353097e

File tree

15 files changed

+459
-38
lines changed

15 files changed

+459
-38
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,30 @@
66

77
namespace Magento\CatalogSearch\Model\ResourceModel\Advanced;
88

9+
use Magento\Catalog\Model\Category;
910
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
12+
use Magento\CatalogSearch\Model\ResourceModel\Advanced;
1013
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker;
1114
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyCheckerInterface;
15+
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverFactory;
1216
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverInterface;
17+
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory;
1318
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierInterface;
14-
use Magento\Framework\Search\EngineResolverInterface;
15-
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverInterface;
1619
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverFactory;
20+
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverInterface;
21+
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
1722
use Magento\Framework\Api\FilterBuilder;
18-
use Magento\Framework\DB\Select;
1923
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
2024
use Magento\Framework\Api\Search\SearchResultFactory;
25+
use Magento\Framework\Api\Search\SearchResultInterface;
26+
use Magento\Framework\App\ObjectManager;
27+
use Magento\Framework\DB\Select;
2128
use Magento\Framework\EntityManager\MetadataPool;
2229
use Magento\Framework\Exception\LocalizedException;
30+
use Magento\Framework\Search\EngineResolverInterface;
2331
use Magento\Framework\Search\Request\EmptyRequestDataException;
2432
use Magento\Framework\Search\Request\NonExistingRequestNameException;
25-
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
26-
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverFactory;
27-
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory;
28-
use Magento\Framework\App\ObjectManager;
29-
use Magento\Framework\Api\Search\SearchResultInterface;
3033

3134
/**
3235
* Advanced search collection
@@ -106,6 +109,11 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
106109
*/
107110
private $defaultFilterStrategyApplyChecker;
108111

112+
/**
113+
* @var Advanced
114+
*/
115+
private $advancedSearchResource;
116+
109117
/**
110118
* Collection constructor
111119
*
@@ -141,6 +149,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
141149
* @param TotalRecordsResolverFactory|null $totalRecordsResolverFactory
142150
* @param EngineResolverInterface|null $engineResolver
143151
* @param DefaultFilterStrategyApplyCheckerInterface|null $defaultFilterStrategyApplyChecker
152+
* @param Advanced|null $advancedSearchResource
144153
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
145154
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
146155
*/
@@ -176,7 +185,8 @@ public function __construct(
176185
SearchResultApplierFactory $searchResultApplierFactory = null,
177186
TotalRecordsResolverFactory $totalRecordsResolverFactory = null,
178187
EngineResolverInterface $engineResolver = null,
179-
DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null
188+
DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null,
189+
Advanced $advancedSearchResource = null
180190
) {
181191
$this->searchRequestName = $searchRequestName;
182192
if ($searchResultFactory === null) {
@@ -193,6 +203,8 @@ public function __construct(
193203
->get(EngineResolverInterface::class);
194204
$this->defaultFilterStrategyApplyChecker = $defaultFilterStrategyApplyChecker ?: ObjectManager::getInstance()
195205
->get(DefaultFilterStrategyApplyChecker::class);
206+
$this->advancedSearchResource = $advancedSearchResource ?: ObjectManager::getInstance()
207+
->get(Advanced::class);
196208
parent::__construct(
197209
$entityFactory,
198210
$logger,
@@ -258,14 +270,14 @@ public function setOrder($attribute, $dir = Select::SQL_DESC)
258270
*/
259271
public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
260272
{
273+
$this->setAttributeFilterData(Category::ENTITY, 'category_ids', $category->getId());
261274
/**
262275
* This changes need in backward compatible reasons for support dynamic improved algorithm
263276
* for price aggregation process.
264277
*/
265278
if ($this->defaultFilterStrategyApplyChecker->isApplicable()) {
266279
parent::addCategoryFilter($category);
267280
} else {
268-
$this->addFieldToFilter('category_ids', $category->getId());
269281
$this->_productLimitationPrice();
270282
}
271283

@@ -278,14 +290,13 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
278290
*/
279291
public function setVisibility($visibility)
280292
{
293+
$this->setAttributeFilterData(Product::ENTITY, 'visibility', $visibility);
281294
/**
282295
* This changes need in backward compatible reasons for support dynamic improved algorithm
283296
* for price aggregation process.
284297
*/
285298
if ($this->defaultFilterStrategyApplyChecker->isApplicable()) {
286299
parent::setVisibility($visibility);
287-
} else {
288-
$this->addFieldToFilter('visibility', $visibility);
289300
}
290301

291302
return $this;
@@ -306,6 +317,25 @@ private function setSearchOrder($field, $direction)
306317
$this->searchOrders[$field] = $direction;
307318
}
308319

320+
/**
321+
* Prepare attribute data to filter.
322+
*
323+
* @param string $entityType
324+
* @param string $attributeCode
325+
* @param mixed $condition
326+
* @return $this
327+
*/
328+
private function setAttributeFilterData(string $entityType, string $attributeCode, $condition): self
329+
{
330+
/** @var AbstractAttribute $attribute */
331+
$attribute = $this->_eavConfig->getAttribute($entityType, $attributeCode);
332+
$table = $attribute->getBackend()->getTable();
333+
$condition = $this->advancedSearchResource->prepareCondition($attribute, $condition);
334+
$this->addFieldsToFilter([$table => [$attributeCode => $condition]]);
335+
336+
return $this;
337+
}
338+
309339
/**
310340
* @inheritdoc
311341
*/
@@ -377,7 +407,7 @@ public function _loadEntities($printQuery = false, $logQuery = false)
377407
$query = $this->getSelect();
378408
$rows = $this->_fetchAll($query);
379409
} catch (\Exception $e) {
380-
$this->printLogQuery(false, true, $query);
410+
$this->printLogQuery(false, true, $query ?? null);
381411
throw $e;
382412
}
383413

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<queryReference clause="should" ref="sku_query"/>
6767
<queryReference clause="should" ref="price_query"/>
6868
<queryReference clause="should" ref="category_query"/>
69+
<queryReference clause="must" ref="visibility_query"/>
6970
</query>
7071
<query name="sku_query" xsi:type="filteredQuery">
7172
<filterReference clause="must" ref="sku_query_filter"/>
@@ -76,11 +77,15 @@
7677
<query name="category_query" xsi:type="filteredQuery">
7778
<filterReference clause="must" ref="category_filter"/>
7879
</query>
80+
<query name="visibility_query" xsi:type="filteredQuery">
81+
<filterReference clause="must" ref="visibility_filter"/>
82+
</query>
7983
</queries>
8084
<filters>
8185
<filter xsi:type="wildcardFilter" name="sku_query_filter" field="sku" value="$sku$"/>
8286
<filter xsi:type="rangeFilter" name="price_query_filter" field="price" from="$price.from$" to="$price.to$"/>
8387
<filter xsi:type="termFilter" name="category_filter" field="category_ids" value="$category_ids$"/>
88+
<filter xsi:type="termFilter" name="visibility_filter" field="visibility" value="$visibility$"/>
8489
</filters>
8590
<from>0</from>
8691
<size>10000</size>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontVerifyCustomerAccountInformationActionGroup">
11+
<arguments>
12+
<argument name="customer"/>
13+
</arguments>
14+
<annotations>
15+
<description>Verifies customer information on the Edit Account Information page on the storefront</description>
16+
</annotations>
17+
<seeInField selector="{{StorefrontCustomerAccountInformationSection.firstName}}" userInput="{{customer.firstname}}" stepKey="seeCustomerFirstName"/>
18+
<seeInField selector="{{StorefrontCustomerAccountInformationSection.lastName}}" userInput="{{customer.lastname}}" stepKey="seeCustomerLastName"/>
19+
<seeElement selector="{{StorefrontCustomerAccountInformationSection.changeEmail}}" stepKey="seeChangeEmail"/>
20+
<seeElement selector="{{StorefrontCustomerAccountInformationSection.changePassword}}" stepKey="seeChangePassword"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Elasticsearch/Model/Advanced/ProductCollectionPrepareStrategy.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*/
66
namespace Magento\Elasticsearch\Model\Advanced;
77

8-
use Magento\Catalog\Model\ResourceModel\Product\Collection;
98
use Magento\Catalog\Model\Config;
9+
use Magento\Catalog\Model\Product\Visibility;
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1011
use Magento\CatalogSearch\Model\Advanced\ProductCollectionPrepareStrategyInterface;
12+
use Magento\Framework\App\ObjectManager;
1113

1214
/**
1315
* Strategy interface for preparing product collection.
@@ -19,13 +21,22 @@ class ProductCollectionPrepareStrategy implements ProductCollectionPrepareStrate
1921
*/
2022
private $catalogConfig;
2123

24+
/**
25+
* @var Visibility
26+
*/
27+
private $catalogProductVisibility;
28+
2229
/**
2330
* @param Config $catalogConfig
31+
* @param Visibility|null $catalogProductVisibility
2432
*/
2533
public function __construct(
26-
Config $catalogConfig
34+
Config $catalogConfig,
35+
Visibility $catalogProductVisibility = null
2736
) {
2837
$this->catalogConfig = $catalogConfig;
38+
$this->catalogProductVisibility = $catalogProductVisibility
39+
?? ObjectManager::getInstance()->get(Visibility::class);
2940
}
3041

3142
/**
@@ -36,6 +47,7 @@ public function prepare(Collection $collection)
3647
$collection
3748
->addAttributeToSelect($this->catalogConfig->getProductAttributes())
3849
->addMinimalPrice()
39-
->addTaxPercents();
50+
->addTaxPercents()
51+
->setVisibility($this->catalogProductVisibility->getVisibleInSearchIds());
4052
}
4153
}

app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function configure()
7474
*/
7575
protected function execute(InputInterface $input, OutputInterface $output)
7676
{
77-
$returnValue = Cli::RETURN_FAILURE;
77+
$returnValue = Cli::RETURN_SUCCESS;
7878
foreach ($this->getIndexers($input) as $indexer) {
7979
try {
8080
$this->validateIndexerStatus($indexer);
@@ -97,14 +97,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
9797
$output->writeln(
9898
__('has been rebuilt successfully in %time', ['time' => gmdate('H:i:s', $resultTime)])
9999
);
100-
$returnValue = Cli::RETURN_SUCCESS;
101100
} catch (LocalizedException $e) {
102101
$output->writeln(__('exception: %message', ['message' => $e->getMessage()]));
102+
$returnValue = Cli::RETURN_FAILURE;
103103
} catch (\Exception $e) {
104104
$output->writeln('process unknown error:');
105105
$output->writeln($e->getMessage());
106106

107107
$output->writeln($e->getTraceAsString(), OutputInterface::VERBOSITY_DEBUG);
108+
$returnValue = Cli::RETURN_FAILURE;
108109
}
109110
}
110111

app/code/Magento/Sales/Block/Order/Recent.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace Magento\Sales\Block\Order;
77

88
use Magento\Framework\View\Element\Template\Context;
9-
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
109
use Magento\Customer\Model\Session;
1110
use Magento\Sales\Model\Order\Config;
11+
use Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface;
1212
use Magento\Store\Model\StoreManagerInterface;
1313
use Magento\Framework\App\ObjectManager;
1414

@@ -26,7 +26,7 @@ class Recent extends \Magento\Framework\View\Element\Template
2626
const ORDER_LIMIT = 5;
2727

2828
/**
29-
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
29+
* @var CollectionFactoryInterface
3030
*/
3131
protected $_orderCollectionFactory;
3232

@@ -47,15 +47,15 @@ class Recent extends \Magento\Framework\View\Element\Template
4747

4848
/**
4949
* @param \Magento\Framework\View\Element\Template\Context $context
50-
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
50+
* @param CollectionFactoryInterface $orderCollectionFactory
5151
* @param \Magento\Customer\Model\Session $customerSession
5252
* @param \Magento\Sales\Model\Order\Config $orderConfig
5353
* @param array $data
5454
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
5555
*/
5656
public function __construct(
5757
Context $context,
58-
CollectionFactory $orderCollectionFactory,
58+
CollectionFactoryInterface $orderCollectionFactory,
5959
Session $customerSession,
6060
Config $orderConfig,
6161
array $data = [],
@@ -84,11 +84,12 @@ protected function _construct()
8484
*/
8585
private function getRecentOrders()
8686
{
87-
$orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
87+
$customerId = $this->_customerSession->getCustomerId();
88+
$orders = $this->_orderCollectionFactory->create($customerId)->addAttributeToSelect(
8889
'*'
8990
)->addAttributeToFilter(
9091
'customer_id',
91-
$this->_customerSession->getCustomerId()
92+
$customerId
9293
)->addAttributeToFilter(
9394
'store_id',
9495
$this->storeManager->getStore()->getId()

app/code/Magento/Sales/CustomerData/LastOrderedItems.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LastOrderedItems implements SectionSourceInterface
2323
const SIDEBAR_ORDER_LIMIT = 5;
2424

2525
/**
26-
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
26+
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface
2727
*/
2828
protected $_orderCollectionFactory;
2929

@@ -68,7 +68,7 @@ class LastOrderedItems implements SectionSourceInterface
6868
private $logger;
6969

7070
/**
71-
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
71+
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface $orderCollectionFactory
7272
* @param \Magento\Sales\Model\Order\Config $orderConfig
7373
* @param \Magento\Customer\Model\Session $customerSession
7474
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
@@ -77,7 +77,7 @@ class LastOrderedItems implements SectionSourceInterface
7777
* @param LoggerInterface $logger
7878
*/
7979
public function __construct(
80-
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
80+
\Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface $orderCollectionFactory,
8181
\Magento\Sales\Model\Order\Config $orderConfig,
8282
\Magento\Customer\Model\Session $customerSession,
8383
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
@@ -103,7 +103,7 @@ protected function initOrders()
103103
{
104104
$customerId = $this->_customerSession->getCustomerId();
105105

106-
$orders = $this->_orderCollectionFactory->create()
106+
$orders = $this->_orderCollectionFactory->create($customerId)
107107
->addAttributeToFilter('customer_id', $customerId)
108108
->addAttributeToFilter('status', ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()])
109109
->addAttributeToSort('created_at', 'desc')
@@ -138,7 +138,7 @@ protected function getItems()
138138
$this->logger->critical($noEntityException);
139139
continue;
140140
}
141-
if (isset($product) && in_array($website, $product->getWebsiteIds())) {
141+
if (in_array($website, $product->getWebsiteIds())) {
142142
$url = $product->isVisibleInSiteVisibility() ? $product->getProductUrl() : null;
143143
$items[] = [
144144
'id' => $item->getId(),
@@ -188,7 +188,7 @@ protected function getLastOrder()
188188
}
189189

190190
/**
191-
* {@inheritdoc}
191+
* @inheritdoc
192192
*/
193193
public function getSectionData()
194194
{

0 commit comments

Comments
 (0)