Skip to content

Commit 676e6ce

Browse files
committed
MAGETWO-93808: [Forwardport] Catalog EAV table getting called instead of flat table on top menu when flat is enabled
1 parent 5d79288 commit 676e6ce

File tree

1 file changed

+28
-0
lines changed
  • app/code/Magento/Catalog/Model/ResourceModel/Category/Flat

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
1313
use Psr\Log\LoggerInterface as Logger;
1414
use Magento\Store\Model\StoreManagerInterface;
15+
use Magento\Store\Model\ScopeInterface;
1516

1617
/**
1718
* Catalog category flat collection
@@ -48,12 +49,20 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
4849
*/
4950
protected $_storeId;
5051

52+
/**
53+
* Core store config
54+
*
55+
* @var \Magento\Framework\App\Config\ScopeConfigInterface
56+
*/
57+
private $scopeConfig;
58+
5159
/**
5260
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
5361
* @param Logger $logger
5462
* @param FetchStrategyInterface $fetchStrategy
5563
* @param ManagerInterface $eventManager
5664
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
65+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
5766
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
5867
* @param AbstractDb $resource
5968
*/
@@ -63,10 +72,12 @@ public function __construct(
6372
FetchStrategyInterface $fetchStrategy,
6473
ManagerInterface $eventManager,
6574
StoreManagerInterface $storeManager,
75+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
6676
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
6777
AbstractDb $resource = null
6878
) {
6979
$this->_storeManager = $storeManager;
80+
$this->scopeConfig = $scopeConfig;
7081
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
7182
}
7283

@@ -387,4 +398,21 @@ public function setPage($pageNum, $pageSize)
387398
$this->setCurPage($pageNum)->setPageSize($pageSize);
388399
return $this;
389400
}
401+
402+
/**
403+
* Add navigation max depth filter
404+
*
405+
* @return $this
406+
*/
407+
public function addNavigationMaxDepthFilter()
408+
{
409+
$navigationMaxDepth = (int)$this->scopeConfig->getValue(
410+
'catalog/navigation/max_depth',
411+
ScopeInterface::SCOPE_STORE
412+
);
413+
if ($navigationMaxDepth > 0) {
414+
$this->addLevelFilter($navigationMaxDepth);
415+
}
416+
return $this;
417+
}
390418
}

0 commit comments

Comments
 (0)