Skip to content

Commit ac82764

Browse files
committed
Fix Integration Test
1 parent 1f35a7f commit ac82764

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/TableResolver.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;
88

99
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\App\State;
1011
use Magento\Store\Model\StoreManagerInterface;
1112
use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
1213
use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
@@ -27,16 +28,24 @@ class TableResolver
2728
*/
2829
private $tableResolver;
2930

31+
/**
32+
* @var State
33+
*/
34+
private $state;
35+
3036
/**
3137
* @param StoreManagerInterface $storeManager
3238
* @param IndexScopeResolver $tableResolver
39+
* @param State $state
3340
*/
3441
public function __construct(
3542
StoreManagerInterface $storeManager,
36-
IndexScopeResolver $tableResolver
43+
IndexScopeResolver $tableResolver,
44+
State $state
3745
) {
3846
$this->storeManager = $storeManager;
3947
$this->tableResolver = $tableResolver;
48+
$this->state = $state;
4049
}
4150

4251
/**
@@ -55,9 +64,12 @@ public function afterGetTableName(
5564
string $result,
5665
$modelEntity
5766
) {
67+
$areaCode = $this->state->getAreaCode();
68+
5869
if (!is_array($modelEntity) &&
5970
$modelEntity === AbstractAction::MAIN_INDEX_TABLE &&
60-
$this->storeManager->getStore()->getId()
71+
$this->storeManager->getStore()->getId() &&
72+
$areaCode != 'adminhtml'
6173
) {
6274
$catalogCategoryProductDimension = new Dimension(
6375
\Magento\Store\Model\Store::ENTITY,

app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,7 @@ private function getProductsCountFromCategoryTable(Category $item, string $websi
567567
*/
568568
private function getProductsCountQuery(array $categoryIds, $addVisibilityFilter = true): Select
569569
{
570-
$connections = $this->_resource->getConnection();
571-
$categoryTable = $connections->getTableName('catalog_category_product_index');
572-
573-
$tablePrefix = $this->_resource->getTablePrefix();
574-
if ($tablePrefix && strpos($categoryTable, $tablePrefix) !== 0) {
575-
$categoryTable = $tablePrefix . $categoryTable;
576-
}
570+
$categoryTable = $this->_resource->getTableName('catalog_category_product_index');
577571

578572
$select = $this->_conn->select()
579573
->from(

0 commit comments

Comments
 (0)