Skip to content

Commit 718d088

Browse files
committed
Merge branch 'ACP2E-685' of https://github.com/magento-l3/magento2ce into L3-PR-2022-04-19-v2
2 parents 583b4dd + c9d8e95 commit 718d088

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,8 @@ public function __construct(
189189
Advanced $advancedSearchResource = null
190190
) {
191191
$this->searchRequestName = $searchRequestName;
192-
if ($searchResultFactory === null) {
193-
$this->searchResultFactory = \Magento\Framework\App\ObjectManager::getInstance()
194-
->get(\Magento\Framework\Api\Search\SearchResultFactory::class);
195-
}
192+
$this->searchResultFactory = $searchResultFactory ?: ObjectManager::getInstance()
193+
->get(SearchResultFactory::class);
196194
$this->searchCriteriaResolverFactory = $searchCriteriaResolverFactory ?: ObjectManager::getInstance()
197195
->get(SearchCriteriaResolverFactory::class);
198196
$this->searchResultApplierFactory = $searchResultApplierFactory ?: ObjectManager::getInstance()
@@ -241,7 +239,7 @@ public function __construct(
241239
public function addFieldsToFilter($fields)
242240
{
243241
if ($fields) {
244-
$this->filters = array_merge($this->filters, $fields);
242+
$this->filters = array_replace_recursive($this->filters, $fields);
245243
}
246244
return $this;
247245
}

dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/Advanced/ResultTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function testExecute(array $searchParams): void
6565
$this->dispatch('catalogsearch/advanced/result');
6666
$responseBody = $this->getResponse()->getBody();
6767
$this->assertStringContainsString('Simple product name', $responseBody);
68+
$this->assertStringNotContainsString('Not visible simple product', $responseBody);
6869
}
6970

7071
/**

dev/tests/integration/testsuite/Magento/CatalogSearch/_files/product_for_search.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
2828
/** @var ProductFactory $productFactory */
2929
$productFactory = $objectManager->get(ProductFactory::class);
30+
3031
$product = $productFactory->create();
3132
$product->isObjectNew(true);
3233
$product->setTypeId(Type::TYPE_SIMPLE)
@@ -54,3 +55,31 @@
5455
]
5556
);
5657
$productRepository->save($product);
58+
59+
$product = $productFactory->create();
60+
$product->isObjectNew(true);
61+
$product->setTypeId(Type::TYPE_SIMPLE)
62+
->setAttributeSetId($product->getDefaultAttributeSetId())
63+
->setWebsiteIds([1])
64+
->setName('Not visible simple product')
65+
->setSku('not_visible_simple')
66+
->setPrice(100)
67+
->setWeight(1)
68+
->setShortDescription('Product short description')
69+
->setTaxClassId(0)
70+
->setDescription('Product description')
71+
->setMetaTitle('meta title')
72+
->setMetaKeyword('meta keyword')
73+
->setMetaDescription('meta description')
74+
->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE)
75+
->setStatus(Status::STATUS_ENABLED)
76+
->setTestSearchableAttribute($attribute->getSource()->getOptionId('Option 1'))
77+
->setStockData(
78+
[
79+
'use_config_manage_stock' => 1,
80+
'qty' => 100,
81+
'is_qty_decimal' => 0,
82+
'is_in_stock' => 1,
83+
]
84+
);
85+
$productRepository->save($product);

0 commit comments

Comments
 (0)