16
16
use Magento \Framework \ObjectManager \ResetAfterRequestInterface ;
17
17
use Magento \Store \Api \Data \StoreInterface ;
18
18
use Magento \Store \Model \Store ;
19
+ use Magento \Catalog \Model \Product \Visibility ;
19
20
20
21
// phpcs:disable Magento2.Classes.AbstractApi
21
22
/**
@@ -134,21 +135,28 @@ abstract class AbstractAction implements ResetAfterRequestInterface
134
135
*/
135
136
private $ currentStore ;
136
137
138
+ /**
139
+ * @var Visibility
140
+ */
141
+ private $ visibility ;
142
+
137
143
/**
138
144
* @param ResourceConnection $resource
139
145
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
140
146
* @param \Magento\Catalog\Model\Config $config
141
147
* @param QueryGenerator $queryGenerator
142
148
* @param MetadataPool|null $metadataPool
143
149
* @param TableMaintainer|null $tableMaintainer
150
+ * @param Visibility|null $visibility
144
151
*/
145
152
public function __construct (
146
153
\Magento \Framework \App \ResourceConnection $ resource ,
147
154
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
148
155
\Magento \Catalog \Model \Config $ config ,
149
156
QueryGenerator $ queryGenerator = null ,
150
157
MetadataPool $ metadataPool = null ,
151
- TableMaintainer $ tableMaintainer = null
158
+ TableMaintainer $ tableMaintainer = null ,
159
+ Visibility $ visibility = null
152
160
) {
153
161
$ this ->resource = $ resource ;
154
162
$ this ->connection = $ resource ->getConnection ();
@@ -157,6 +165,7 @@ public function __construct(
157
165
$ this ->queryGenerator = $ queryGenerator ?: ObjectManager::getInstance ()->get (QueryGenerator::class);
158
166
$ this ->metadataPool = $ metadataPool ?: ObjectManager::getInstance ()->get (MetadataPool::class);
159
167
$ this ->tableMaintainer = $ tableMaintainer ?: ObjectManager::getInstance ()->get (TableMaintainer::class);
168
+ $ this ->visibility = $ visibility ?: ObjectManager::getInstance ()->get (Visibility::class);
160
169
}
161
170
162
171
/**
@@ -365,11 +374,7 @@ protected function getNonAnchorCategoriesSelect(Store $store)
365
374
\Magento \Catalog \Model \Product \Attribute \Source \Status::STATUS_ENABLED
366
375
)->where (
367
376
$ 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 ()
373
378
)->columns (
374
379
[
375
380
'category_id ' => 'cc.entity_id ' ,
@@ -610,11 +615,7 @@ protected function createAnchorSelect(Store $store)
610
615
\Magento \Catalog \Model \Product \Attribute \Source \Status::STATUS_ENABLED
611
616
)->where (
612
617
$ 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 ()
618
619
)->where (
619
620
$ this ->connection ->getIfNullSql ('ccas.value ' , 'ccad.value ' ) . ' = ? ' ,
620
621
1
@@ -858,11 +859,7 @@ protected function getAllProducts(Store $store)
858
859
\Magento \Catalog \Model \Product \Attribute \Source \Status::STATUS_ENABLED
859
860
)->where (
860
861
$ 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 ()
866
863
)->group (
867
864
'cp.entity_id '
868
865
)->columns (
0 commit comments