14
14
use IntegerNet \Solr \Implementor \Product as ProductInterface ;
15
15
use IntegerNet \Solr \Implementor \ProductRenderer as ProductRendererInterface ;
16
16
use IntegerNet \Solr \Indexer \IndexDocument ;
17
+ use IntegerNet \Solr \Model \Config \FrontendStoresConfig ;
17
18
use Magento \Framework \App \State as AppState ;
18
19
use Magento \Framework \View \LayoutInterface ;
19
20
@@ -27,10 +28,18 @@ class ProductRenderer implements ProductRendererInterface
27
28
* @var AppState
28
29
*/
29
30
private $ appState ;
31
+ /**
32
+ * @var FrontendStoresConfig
33
+ */
34
+ private $ storesConfig ;
35
+ /**
36
+ * @var bool
37
+ */
30
38
private $ isLayoutLoaded = false ;
31
39
32
- public function __construct (LayoutInterface \Proxy $ layout , AppState $ appState )
40
+ public function __construct (LayoutInterface \Proxy $ layout , AppState $ appState, FrontendStoresConfig $ storesConfig )
33
41
{
42
+ $ this ->storesConfig = $ storesConfig ;
34
43
$ this ->layout = $ layout ;
35
44
$ this ->appState = $ appState ;
36
45
}
@@ -65,7 +74,9 @@ public function addResultHtmlToProductData(ProductInterface $product, IndexDocum
65
74
// We need direct access to the Magento product
66
75
throw new \InvalidArgumentException ('Magento 2 product bridge expected, ' . get_class ($ product ) .' received. ' );
67
76
}
68
- $ this ->addAutosuggestItemHtml ($ product , $ productData );
77
+ if ($ this ->storesConfig ->byStoreId ($ product ->getStoreId ())->getAutosuggestConfig ()->isActive ()) {
78
+ $ this ->addAutosuggestItemHtml ($ product , $ productData );
79
+ }
69
80
//TODO if $useHtmlInResult, render product list and grid HTML
70
81
}
71
82
0 commit comments