Skip to content

Commit da7f3c4

Browse files
committed
MAGETWO-88962: [UI Component] URL Input: Product Link
1 parent cdc982a commit da7f3c4

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

app/code/Magento/CatalogInventory/Model/Plugin/ProductSearch.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,26 @@
99
namespace Magento\CatalogInventory\Model\Plugin;
1010

1111
use Magento\CatalogInventory\Helper\Stock;
12-
use Magento\CatalogInventory\Model\Configuration;
1312

13+
/** Plugin to add stock filter depends on configuration */
1414
class ProductSearch
1515
{
16-
/**
17-
* @var Configuration
18-
*/
19-
private $configuration;
20-
2116
/**
2217
* @var Stock
2318
*/
2419
private $stockHelper;
2520

2621
/**
27-
* ProductLinks constructor.
28-
*
29-
* @param Configuration $configuration
3022
* @param Stock $stockHelper
3123
*/
32-
public function __construct(Configuration $configuration, Stock $stockHelper)
24+
public function __construct(Stock $stockHelper)
3325
{
34-
$this->configuration = $configuration;
3526
$this->stockHelper = $stockHelper;
3627
}
3728

3829
/**
30+
* Adds stock filter depends on configuration
31+
*
3932
* @param \Magento\Catalog\Model\ProductLink\Search $subject
4033
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
4134
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,23 @@ public function testExecuteNonExistingSearchKey() : void
4040
$responseBody = $this->getResponse()->getBody();
4141
$this->assertContains('{"options":[],"total":0}', $responseBody);
4242
}
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+
}
4362
}

0 commit comments

Comments
 (0)