Skip to content

Commit ec125a7

Browse files
authored
Merge pull request #4556 from magento-obsessive-owls/MC-18009
[Owls] MC-18009: Disabled Products Do Not Appear in Search Results of Link Attribute
2 parents 26794cb + 0bce8c2 commit ec125a7

File tree

2 files changed

+24
-4
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product

2 files changed

+24
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
use Magento\Catalog\Api\Data\ProductInterface;
1212

13-
/** Returns collection of product visible in catalog by search key */
13+
/**
14+
* Returns collection of product visible in catalog by search key
15+
*/
1416
class Search
1517
{
1618
/**
@@ -58,7 +60,6 @@ public function prepareCollection(
5860
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
5961
$productCollection = $this->productCollectionFactory->create();
6062
$productCollection->addAttributeToSelect(ProductInterface::NAME);
61-
$productCollection->setVisibility($this->catalogVisibility->getVisibleInCatalogIds());
6263
$productCollection->setPage($pageNum, $limit);
6364
$this->filter->addFilter($productCollection, 'fulltext', ['fulltext' => $searchKey]);
6465
$productCollection->setPage($pageNum, $limit);

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/SearchTest.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function testExecuteNonExistingSearchKey() : void
3838
->setPostValue('limit', 50);
3939
$this->dispatch('backend/catalog/product/search');
4040
$responseBody = $this->getResponse()->getBody();
41-
$this->assertContains('{"options":[],"total":0}', $responseBody);
41+
$jsonResponse = json_decode($responseBody, true);
42+
$this->assertEmpty($jsonResponse['options']);
4243
}
4344

4445
/**
@@ -57,6 +58,24 @@ public function testExecuteNotVisibleIndividuallyProducts() : void
5758
->setPostValue('limit', 50);
5859
$this->dispatch('backend/catalog/product/search');
5960
$responseBody = $this->getResponse()->getBody();
60-
$this->assertContains('{"options":[],"total":0}', $responseBody);
61+
$jsonResponse = json_decode($responseBody, true);
62+
$this->assertEquals(1, $jsonResponse['total']);
63+
$this->assertCount(1, $jsonResponse['options']);
64+
}
65+
66+
/**
67+
* @magentoDataFixture Magento/Catalog/_files/multiple_mixed_products.php
68+
*/
69+
public function testExecuteEnabledAndDisabledProducts() : void
70+
{
71+
$this->getRequest()
72+
->setPostValue('searchKey', 'simple')
73+
->setPostValue('page', 1)
74+
->setPostValue('limit', 50);
75+
$this->dispatch('backend/catalog/product/search');
76+
$responseBody = $this->getResponse()->getBody();
77+
$jsonResponse = json_decode($responseBody, true);
78+
$this->assertEquals(7, $jsonResponse['total']);
79+
$this->assertCount(7, $jsonResponse['options']);
6180
}
6281
}

0 commit comments

Comments
 (0)