Skip to content

Commit 34a08b4

Browse files
committed
MAGE-940 Add constants for clarity of visibility values
1 parent b631497 commit 34a08b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Observer/RecommendSettings.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
use Algolia\AlgoliaSearch\Api\RecommendManagementInterface;
77
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
88
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Model\Product\Visibility;
910
use Magento\Framework\Api\SearchCriteriaBuilder;
1011
use Magento\Framework\App\Config\Storage\WriterInterface;
11-
use Magento\Framework\Event\ObserverInterface;
1212
use Magento\Framework\Event\Observer;
13+
use Magento\Framework\Event\ObserverInterface;
1314
use Magento\Framework\Exception\LocalizedException;
1415

1516
class RecommendSettings implements ObserverInterface
@@ -168,7 +169,14 @@ protected function getProductId(): string
168169
$searchCriteria = $this->searchCriteriaBuilder
169170
->addFilter(self::STATUS, 1)
170171
->addFilter(self::QUANTITY_AND_STOCK_STATUS, 1)
171-
->addFilter(self::VISIBILITY, [2, 3, 4], 'in')
172+
->addFilter(
173+
self::VISIBILITY,
174+
[
175+
Visibility::VISIBILITY_IN_CATALOG,
176+
Visibility::VISIBILITY_IN_SEARCH,
177+
Visibility::VISIBILITY_BOTH
178+
],
179+
'in')
172180
->setPageSize(10)
173181
->create();
174182
$result = $this->productRepository->getList($searchCriteria);

0 commit comments

Comments
 (0)