9
9
*/
10
10
namespace Magento \Search \Block ;
11
11
12
+ use Magento \Framework \DataObject ;
13
+ use Magento \Framework \Exception \NoSuchEntityException ;
12
14
use Magento \Framework \UrlFactory ;
13
15
use Magento \Framework \UrlInterface ;
14
16
use Magento \Framework \View \Element \Template ;
15
17
use Magento \Framework \View \Element \Template \Context ;
16
18
use Magento \Search \Model \ResourceModel \Query \CollectionFactory ;
17
19
18
20
/**
21
+ * Terms and conditions block
22
+ *
19
23
* @api
20
24
* @since 100.0.2
21
25
*/
@@ -71,17 +75,17 @@ public function __construct(
71
75
* Load terms and try to sort it by names
72
76
*
73
77
* @return $this
74
- * @throws \Magento\Framework\Exception\ NoSuchEntityException
78
+ * @throws NoSuchEntityException
75
79
*/
76
80
protected function _loadTerms ()
77
81
{
78
82
if (empty ($ this ->_terms )) {
79
83
$ 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 ();
85
89
86
90
if (count ($ terms ) == 0 ) {
87
91
return $ this ;
@@ -91,6 +95,7 @@ protected function _loadTerms()
91
95
$ this ->_minPopularity = end ($ terms )->getPopularity ();
92
96
$ range = $ this ->_maxPopularity - $ this ->_minPopularity ;
93
97
$ range = $ range == 0 ? 1 : $ range ;
98
+ $ termKeys = [];
94
99
foreach ($ terms as $ term ) {
95
100
if (!$ term ->getPopularity ()) {
96
101
continue ;
@@ -112,8 +117,10 @@ protected function _loadTerms()
112
117
}
113
118
114
119
/**
120
+ * Load and return terms
121
+ *
115
122
* @return array
116
- * @throws \Magento\Framework\Exception\ NoSuchEntityException
123
+ * @throws NoSuchEntityException
117
124
*/
118
125
public function getTerms ()
119
126
{
@@ -122,10 +129,12 @@ public function getTerms()
122
129
}
123
130
124
131
/**
125
- * @param \Magento\Framework\DataObject $obj
132
+ * Return search url
133
+ *
134
+ * @param DataObject $obj
126
135
* @return string
127
136
*/
128
- public function getSearchUrl ($ obj )
137
+ public function getSearchUrl (DataObject $ obj )
129
138
{
130
139
/** @var $url UrlInterface */
131
140
$ url = $ this ->_urlFactory ->create ();
@@ -138,6 +147,8 @@ public function getSearchUrl($obj)
138
147
}
139
148
140
149
/**
150
+ * Return max popularity
151
+ *
141
152
* @return int
142
153
*/
143
154
public function getMaxPopularity ()
@@ -146,6 +157,8 @@ public function getMaxPopularity()
146
157
}
147
158
148
159
/**
160
+ * Return min popularity
161
+ *
149
162
* @return int
150
163
*/
151
164
public function getMinPopularity ()
0 commit comments