Skip to content

Commit 54d6fa0

Browse files
committed
MC-19633: Disabled Products Do Not Appear in Search Results of Link Attribute
- update to show all products regardless of status
1 parent fcca82e commit 54d6fa0

File tree

2 files changed

+21
-3
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product

2 files changed

+21
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ 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());
6463
$productCollection->setPage($pageNum, $limit);
6564
$this->filter->addFilter($productCollection, 'fulltext', ['fulltext' => $searchKey]);
6665
$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)