File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed
app/code/Magento/CatalogInventory/Model/Plugin
dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 9
9
namespace Magento \CatalogInventory \Model \Plugin ;
10
10
11
11
use Magento \CatalogInventory \Helper \Stock ;
12
- use Magento \CatalogInventory \Model \Configuration ;
13
12
13
+ /** Plugin to add stock filter depends on configuration */
14
14
class ProductSearch
15
15
{
16
- /**
17
- * @var Configuration
18
- */
19
- private $ configuration ;
20
-
21
16
/**
22
17
* @var Stock
23
18
*/
24
19
private $ stockHelper ;
25
20
26
21
/**
27
- * ProductLinks constructor.
28
- *
29
- * @param Configuration $configuration
30
22
* @param Stock $stockHelper
31
23
*/
32
- public function __construct (Configuration $ configuration , Stock $ stockHelper )
24
+ public function __construct (Stock $ stockHelper )
33
25
{
34
- $ this ->configuration = $ configuration ;
35
26
$ this ->stockHelper = $ stockHelper ;
36
27
}
37
28
38
29
/**
30
+ * Adds stock filter depends on configuration
31
+ *
39
32
* @param \Magento\Catalog\Model\ProductLink\Search $subject
40
33
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
41
34
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
Original file line number Diff line number Diff line change @@ -40,4 +40,23 @@ public function testExecuteNonExistingSearchKey() : void
40
40
$ responseBody = $ this ->getResponse ()->getBody ();
41
41
$ this ->assertContains ('{"options":[],"total":0} ' , $ responseBody );
42
42
}
43
+
44
+ /**
45
+ * @magentoDataFixture Magento/Catalog/_files/categories.php
46
+ */
47
+ public function testExecuteNotVisibleIndividuallyProducts () : void
48
+ {
49
+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
50
+ $ productRepository = $ objectManager ->get (\Magento \Catalog \Api \ProductRepositoryInterface::class);
51
+
52
+ $ product = $ productRepository ->get ('simple-3 ' );
53
+ $ this ->assertEquals ('simple-3 ' , $ product ->getSku ());
54
+ $ this ->getRequest ()
55
+ ->setPostValue ('searchKey ' , 'simple-3 ' )
56
+ ->setPostValue ('page ' , 1 )
57
+ ->setPostValue ('limit ' , 50 );
58
+ $ this ->dispatch ('backend/catalog/product/search ' );
59
+ $ responseBody = $ this ->getResponse ()->getBody ();
60
+ $ this ->assertContains ('{"options":[],"total":0} ' , $ responseBody );
61
+ }
43
62
}
You can’t perform that action at this time.
0 commit comments