Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\Product\Visibility;

// phpcs:disable Magento2.Classes.AbstractApi
/**
Expand Down Expand Up @@ -134,21 +135,28 @@ abstract class AbstractAction implements ResetAfterRequestInterface
*/
private $currentStore;

/**
* @var Visibility
*/
private $visibility;

/**
* @param ResourceConnection $resource
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Config $config
* @param QueryGenerator $queryGenerator
* @param MetadataPool|null $metadataPool
* @param TableMaintainer|null $tableMaintainer
* @param Visibility|null $visibility
*/
public function __construct(
\Magento\Framework\App\ResourceConnection $resource,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Config $config,
QueryGenerator $queryGenerator = null,
MetadataPool $metadataPool = null,
TableMaintainer $tableMaintainer = null
TableMaintainer $tableMaintainer = null,
Visibility $visibility = null
) {
$this->resource = $resource;
$this->connection = $resource->getConnection();
Expand All @@ -157,6 +165,7 @@ public function __construct(
$this->queryGenerator = $queryGenerator ?: ObjectManager::getInstance()->get(QueryGenerator::class);
$this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(MetadataPool::class);
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
$this->visibility = $visibility ?: ObjectManager::getInstance()->get(Visibility::class);
}

/**
Expand Down Expand Up @@ -365,11 +374,7 @@ protected function getNonAnchorCategoriesSelect(Store $store)
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
)->where(
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
[
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
]
$this->visibility->getVisibleInSiteIds()
)->columns(
[
'category_id' => 'cc.entity_id',
Expand Down Expand Up @@ -610,11 +615,7 @@ protected function createAnchorSelect(Store $store)
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
)->where(
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
[
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
]
$this->visibility->getVisibleInSiteIds()
)->where(
$this->connection->getIfNullSql('ccas.value', 'ccad.value') . ' = ?',
1
Expand Down Expand Up @@ -858,11 +859,7 @@ protected function getAllProducts(Store $store)
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
)->where(
$this->connection->getIfNullSql('cpvs.value', 'cpvd.value') . ' IN (?)',
[
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH,
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
]
$this->visibility->getVisibleInSiteIds()
)->group(
'cp.entity_id'
)->columns(
Expand Down