55
66use Magento \Framework \App \ResourceConnection ;
77use IntegerNet \AsyncVarnish \Model \ResourceModel \Tag as TagResource ;
8+ use Magento \Framework \App \Config \ScopeConfigInterface ;
89
910class TagRepository
1011{
@@ -16,7 +17,7 @@ class TagRepository
1617 /**
1718 * Limits the amount of tags being fetched from database
1819 */
19- const TAG_LIMIT = 1000000 ;
20+ const FETCH_TAG_LIMIT_CONFIG_PATH = ' system/full_page_cache/async_varnish/varnish_fetch_tag_limit ' ;
2021
2122 private $ lastUsedId ;
2223
@@ -35,16 +36,25 @@ class TagRepository
3536 */
3637 private $ tagResource ;
3738
39+ private $ scopeConfig ;
40+
3841 /**
3942 * @param \Magento\Framework\App\ResourceConnection $resource
4043 */
4144 public function __construct (
4245 ResourceConnection $ resource ,
43- TagResource $ tagResource
46+ TagResource $ tagResource ,
47+ ScopeConfigInterface $ scopeConfig
4448 ) {
4549 $ this ->connection = $ resource ->getConnection ();
4650 $ this ->resource = $ resource ;
4751 $ this ->tagResource = $ tagResource ;
52+ $ this ->scopeConfig = $ scopeConfig ;
53+ }
54+
55+ private function getTagFetchLimit ()
56+ {
57+ return $ this ->scopeConfig ->getValue (self ::FETCH_TAG_LIMIT_CONFIG_PATH );
4858 }
4959
5060 /**
@@ -102,8 +112,9 @@ public function getAll()
102112 $ tags = [];
103113
104114 $ tagResource = $ this ->tagResource ;
115+ $ tagFetchLimit = $ this ->getTagFetchLimit ();
105116
106- $ maxIdResult = $ tagResource ->getMaxTagId (self :: TAG_LIMIT );
117+ $ maxIdResult = $ tagResource ->getMaxTagId ($ tagFetchLimit );
107118
108119 if (empty ($ maxIdResult )) {
109120 return $ tags ;
0 commit comments