99 */
1010namespace Magento \Search \Block ;
1111
12+ use Magento \Framework \DataObject ;
13+ use Magento \Framework \Exception \NoSuchEntityException ;
1214use Magento \Framework \UrlFactory ;
1315use Magento \Framework \UrlInterface ;
1416use Magento \Framework \View \Element \Template ;
1517use Magento \Framework \View \Element \Template \Context ;
1618use Magento \Search \Model \ResourceModel \Query \CollectionFactory ;
1719
1820/**
21+ * Terms and conditions block
22+ *
1923 * @api
2024 * @since 100.0.2
2125 */
@@ -71,17 +75,17 @@ public function __construct(
7175 * Load terms and try to sort it by names
7276 *
7377 * @return $this
74- * @throws \Magento\Framework\Exception\ NoSuchEntityException
78+ * @throws NoSuchEntityException
7579 */
7680 protected function _loadTerms ()
7781 {
7882 if (empty ($ this ->_terms )) {
7983 $ this ->_terms = [];
80- $ terms = $ this ->_queryCollectionFactory ->create ()-> setPopularQueryFilter (
81- $ this ->_storeManager ->getStore ()->getId ()
82- ) ->setPageSize (
83- 100
84- )-> load () ->getItems ();
84+ $ terms = $ this ->_queryCollectionFactory ->create ()
85+ -> setPopularQueryFilter ( $ this ->_storeManager ->getStore ()->getId () )
86+ ->setPageSize (100 )
87+ -> load ()
88+ ->getItems ();
8589
8690 if (count ($ terms ) == 0 ) {
8791 return $ this ;
@@ -91,6 +95,7 @@ protected function _loadTerms()
9195 $ this ->_minPopularity = end ($ terms )->getPopularity ();
9296 $ range = $ this ->_maxPopularity - $ this ->_minPopularity ;
9397 $ range = $ range == 0 ? 1 : $ range ;
98+ $ termKeys = [];
9499 foreach ($ terms as $ term ) {
95100 if (!$ term ->getPopularity ()) {
96101 continue ;
@@ -112,8 +117,10 @@ protected function _loadTerms()
112117 }
113118
114119 /**
120+ * Load and return terms
121+ *
115122 * @return array
116- * @throws \Magento\Framework\Exception\ NoSuchEntityException
123+ * @throws NoSuchEntityException
117124 */
118125 public function getTerms ()
119126 {
@@ -122,10 +129,12 @@ public function getTerms()
122129 }
123130
124131 /**
125- * @param \Magento\Framework\DataObject $obj
132+ * Return search url
133+ *
134+ * @param DataObject $obj
126135 * @return string
127136 */
128- public function getSearchUrl ($ obj )
137+ public function getSearchUrl (DataObject $ obj )
129138 {
130139 /** @var $url UrlInterface */
131140 $ url = $ this ->_urlFactory ->create ();
@@ -138,6 +147,8 @@ public function getSearchUrl($obj)
138147 }
139148
140149 /**
150+ * Return max popularity
151+ *
141152 * @return int
142153 */
143154 public function getMaxPopularity ()
@@ -146,6 +157,8 @@ public function getMaxPopularity()
146157 }
147158
148159 /**
160+ * Return min popularity
161+ *
149162 * @return int
150163 */
151164 public function getMinPopularity ()
0 commit comments