Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Options.php
Go to the documentation of this file.
1 <?php
9 
15 {
19  protected $_request;
20 
24  protected $_registryManager;
25 
30 
36  public function __construct(
37  \Magento\Framework\App\RequestInterface $request,
38  \Magento\Framework\Registry $registry,
39  \Magento\AdvancedSearch\Model\ResourceModel\Recommendations $searchResourceModel
40  ) {
41  $this->_request = $request;
42  $this->_registryManager = $registry;
43  $this->_searchResourceModel = $searchResourceModel;
44  }
45 
49  public function toOptionArray()
50  {
51  $queries = $this->_request->getPost('selected_queries');
52 
53  $currentQueryId = $this->_registryManager->registry('current_catalog_search')->getId();
54  $queryIds = [];
55  if ($queries === null && !empty($currentQueryId)) {
56  $queryIds = $this->_searchResourceModel->getRelatedQueries($currentQueryId);
57  }
58  return $queryIds;
59  }
60 }
__construct(\Magento\Framework\App\RequestInterface $request, \Magento\Framework\Registry $registry, \Magento\AdvancedSearch\Model\ResourceModel\Recommendations $searchResourceModel)
Definition: Options.php:36