Skip to content

Commit 4be01f6

Browse files
Indrani SonawaneIndrani Sonawane
authored andcommitted
Merge remote-tracking branch '37199/category-product-indexer-visibility-fix' into community_prs_march
2 parents 0be139b + 70e4fcb commit 4be01f6

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1717
use Magento\Store\Api\Data\StoreInterface;
1818
use Magento\Store\Model\Store;
19+
use Magento\Catalog\Model\Product\Visibility;
1920

2021
// phpcs:disable Magento2.Classes.AbstractApi
2122
/**
@@ -134,21 +135,28 @@ abstract class AbstractAction implements ResetAfterRequestInterface
134135
*/
135136
private $currentStore;
136137

138+
/**
139+
* @var Visibility
140+
*/
141+
private $visibility;
142+
137143
/**
138144
* @param ResourceConnection $resource
139145
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
140146
* @param \Magento\Catalog\Model\Config $config
141147
* @param QueryGenerator $queryGenerator
142148
* @param MetadataPool|null $metadataPool
143149
* @param TableMaintainer|null $tableMaintainer
150+
* @param Visibility|null $visibility
144151
*/
145152
public function __construct(
146153
\Magento\Framework\App\ResourceConnection $resource,
147154
\Magento\Store\Model\StoreManagerInterface $storeManager,
148155
\Magento\Catalog\Model\Config $config,
149156
QueryGenerator $queryGenerator = null,
150157
MetadataPool $metadataPool = null,
151-
TableMaintainer $tableMaintainer = null
158+
TableMaintainer $tableMaintainer = null,
159+
Visibility $visibility = null
152160
) {
153161
$this->resource = $resource;
154162
$this->connection = $resource->getConnection();
@@ -157,6 +165,7 @@ public function __construct(
157165
$this->queryGenerator = $queryGenerator ?: ObjectManager::getInstance()->get(QueryGenerator::class);
158166
$this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(MetadataPool::class);
159167
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
168+
$this->visibility = $visibility ?: ObjectManager::getInstance()->get(Visibility::class);
160169
}
161170

162171
/**
@@ -365,11 +374,7 @@ protected function getNonAnchorCategoriesSelect(Store $store)
365374
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
366375
)->where(
367376
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
368-
[
369-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
370-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
371-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
372-
]
377+
$this->visibility->getVisibleInSiteIds()
373378
)->columns(
374379
[
375380
'category_id' => 'cc.entity_id',
@@ -610,11 +615,7 @@ protected function createAnchorSelect(Store $store)
610615
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
611616
)->where(
612617
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
613-
[
614-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
615-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
616-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
617-
]
618+
$this->visibility->getVisibleInSiteIds()
618619
)->where(
619620
$this->connection->getIfNullSql('ccas.value', 'ccad.value') . ' = ?',
620621
1
@@ -858,11 +859,7 @@ protected function getAllProducts(Store $store)
858859
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
859860
)->where(
860861
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
861-
[
862-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
863-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
864-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
865-
]
862+
$this->visibility->getVisibleInSiteIds()
866863
)->group(
867864
'cp.entity_id'
868865
)->columns(

0 commit comments

Comments
 (0)