Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #167 from EmicoEcommerce/bug/issue-134842-visibili…
Browse files Browse the repository at this point in the history
…ty-auto-complete

Add visibility filter to product collection in autocomplete data provider helper
  • Loading branch information
Hnto authored Jun 23, 2021
2 parents ae45d73 + 4566a5b commit 22962ce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Model/Autocomplete/DataProviderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Layer\Category\CollectionFilter;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Exception\LocalizedException;
Expand Down Expand Up @@ -134,6 +135,10 @@ public function getProductItems(AutocompleteProductResponseInterface $response)
$productCollection = $this->productCollectionFactory->create();
$productCollection->setStore($this->storeManager->getStore());
$productCollection->addAttributeToFilter('entity_id', ['in' => $response->getProductIds()]);
$productCollection->addFieldToFilter('visibility', ['in' => [
Visibility::VISIBILITY_BOTH,
Visibility::VISIBILITY_IN_SEARCH
]]);
$this->collectionFilter->filter($productCollection, $this->getCategory());

$result = [];
Expand Down

0 comments on commit 22962ce

Please sign in to comment.