Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit e501f67

Browse files
Merge branch '2.3-develop' of https://github.com/magento/magento2 into 2.3-develop
2 parents b032bbc + dea8b32 commit e501f67

File tree

247 files changed

+24768
-1178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+24768
-1178
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ addons:
1313
- magento2.travis
1414
services:
1515
- rabbitmq
16+
- elasticsearch
1617
language: php
1718
php:
1819
- 7.0
@@ -49,7 +50,9 @@ cache:
4950
- $HOME/.nvm
5051
- $HOME/node_modules
5152
- $HOME/yarn.lock
52-
before_install: ./dev/travis/before_install.sh
53+
before_install:
54+
- curl -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.0/elasticsearch-2.3.0.deb && sudo dpkg -i --force-confnew elasticsearch-2.3.0.deb && sudo service elasticsearch restart
55+
- ./dev/travis/before_install.sh
5356
install: composer install --no-interaction
5457
before_script: ./dev/travis/before_script.sh
5558
script:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block\Adminhtml\Search;
7+
8+
/**
9+
* Search queries relations grid container
10+
*
11+
* @api
12+
* @author Magento Core Team <[email protected]>
13+
* @since 100.0.2
14+
*/
15+
class Edit extends \Magento\Backend\Block\Widget\Grid\Container
16+
{
17+
/**
18+
* Enable grid container
19+
*
20+
* @return void
21+
*/
22+
protected function _construct()
23+
{
24+
$this->_blockGroup = 'Magento_AdvancedSearch';
25+
$this->_controller = 'adminhtml_search';
26+
$this->_headerText = __('Related Search Terms');
27+
$this->_addButtonLabel = __('Add New Search Term');
28+
parent::_construct();
29+
$this->buttonList->remove('add');
30+
}
31+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block\Adminhtml\Search;
7+
8+
/**
9+
* Search query relations edit grid
10+
*
11+
* @api
12+
* @author Magento Core Team <[email protected]>
13+
* @since 100.0.2
14+
*/
15+
class Grid extends \Magento\Backend\Block\Widget\Grid
16+
{
17+
/**
18+
* @var \Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options
19+
*/
20+
protected $_options;
21+
22+
/**
23+
* @var \Magento\Framework\Registry
24+
*/
25+
protected $_registryManager;
26+
27+
/**
28+
* @var \Magento\Framework\Json\Helper\Data
29+
*/
30+
protected $jsonHelper;
31+
32+
/**
33+
* @param \Magento\Backend\Block\Template\Context $context
34+
* @param \Magento\Backend\Helper\Data $backendHelper
35+
* @param \Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options $options
36+
* @param \Magento\Framework\Registry $registry
37+
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
38+
* @param array $data
39+
*/
40+
public function __construct(
41+
\Magento\Backend\Block\Template\Context $context,
42+
\Magento\Backend\Helper\Data $backendHelper,
43+
\Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options $options,
44+
\Magento\Framework\Registry $registry,
45+
\Magento\Framework\Json\Helper\Data $jsonHelper,
46+
array $data = []
47+
) {
48+
$this->jsonHelper = $jsonHelper;
49+
parent::__construct($context, $backendHelper, $data);
50+
$this->_options = $options;
51+
$this->_registryManager = $registry;
52+
$this->setDefaultFilter(['query_id_selected' => 1]);
53+
}
54+
55+
/**
56+
* Retrieve a value from registry by a key
57+
*
58+
* @return mixed
59+
*/
60+
public function getQuery()
61+
{
62+
return $this->_registryManager->registry('current_catalog_search');
63+
}
64+
65+
/**
66+
* Add column filter to collection
67+
*
68+
* @param \Magento\Backend\Block\Widget\Grid\Column $column
69+
* @return $this
70+
*/
71+
protected function _addColumnFilterToCollection($column)
72+
{
73+
// Set custom filter for query selected flag
74+
if ($column->getId() == 'query_id_selected' && $this->getQuery()->getId()) {
75+
$selectedIds = $this->getSelectedQueries();
76+
if (empty($selectedIds)) {
77+
$selectedIds = 0;
78+
}
79+
if ($column->getFilter()->getValue()) {
80+
$this->getCollection()->addFieldToFilter('query_id', ['in' => $selectedIds]);
81+
} elseif (!empty($selectedIds)) {
82+
$this->getCollection()->addFieldToFilter('query_id', ['nin' => $selectedIds]);
83+
}
84+
} else {
85+
parent::_addColumnFilterToCollection($column);
86+
}
87+
return $this;
88+
}
89+
90+
/**
91+
* Retrieve selected related queries from grid
92+
*
93+
* @return array
94+
*/
95+
public function getSelectedQueries()
96+
{
97+
return $this->_options->toOptionArray();
98+
}
99+
100+
/**
101+
* Get queries json
102+
*
103+
* @return string
104+
*/
105+
public function getQueriesJson()
106+
{
107+
$queries = array_flip($this->getSelectedQueries());
108+
if (!empty($queries)) {
109+
return $this->jsonHelper->jsonEncode($queries);
110+
}
111+
return '{}';
112+
}
113+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Search engine test connection block
10+
* @api
11+
* @since 100.1.0
12+
*/
13+
class TestConnection extends \Magento\Config\Block\System\Config\Form\Field
14+
{
15+
/**
16+
* Set template to itself
17+
*
18+
* @return $this
19+
* @since 100.1.0
20+
*/
21+
protected function _prepareLayout()
22+
{
23+
parent::_prepareLayout();
24+
$this->setTemplate('Magento_AdvancedSearch::system/config/testconnection.phtml');
25+
return $this;
26+
}
27+
28+
/**
29+
* Unset some non-related element parameters
30+
*
31+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
32+
* @return string
33+
* @since 100.1.0
34+
*/
35+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
36+
{
37+
$element = clone $element;
38+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
39+
return parent::render($element);
40+
}
41+
42+
/**
43+
* Get the button and scripts contents
44+
*
45+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
46+
* @return string
47+
* @since 100.1.0
48+
*/
49+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
50+
{
51+
$originalData = $element->getOriginalData();
52+
$this->addData(
53+
[
54+
'button_label' => __($originalData['button_label']),
55+
'html_id' => $element->getHtmlId(),
56+
'ajax_url' => $this->_urlBuilder->getUrl('catalog/search_system_config/testconnection'),
57+
'field_mapping' => str_replace('"', '\\"', json_encode($this->_getFieldMapping()))
58+
]
59+
);
60+
61+
return $this->_toHtml();
62+
}
63+
64+
/**
65+
* Returns configuration fields required to perform the ping request
66+
*
67+
* @return array
68+
* @since 100.1.0
69+
*/
70+
protected function _getFieldMapping()
71+
{
72+
return ['engine' => 'catalog_search_engine'];
73+
}
74+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block;
7+
8+
/**
9+
* @api
10+
* @since 100.0.2
11+
*/
12+
class Recommendations extends SearchData
13+
{
14+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block;
7+
8+
use Magento\Framework\View\Element\Template;
9+
use Magento\Search\Model\QueryFactoryInterface;
10+
use Magento\Search\Model\QueryInterface;
11+
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
12+
13+
abstract class SearchData extends Template implements SearchDataInterface
14+
{
15+
/**
16+
* @var QueryInterface
17+
*/
18+
private $query;
19+
20+
/**
21+
* @var string
22+
*/
23+
protected $title;
24+
25+
/**
26+
* @var SuggestedQueriesInterface
27+
*/
28+
private $searchDataProvider;
29+
30+
/**
31+
* @var string
32+
*/
33+
protected $_template = 'search_data.phtml';
34+
35+
/**
36+
* @param Template\Context $context
37+
* @param SuggestedQueriesInterface $searchDataProvider
38+
* @param QueryFactoryInterface $queryFactory
39+
* @param string $title
40+
* @param array $data
41+
*/
42+
public function __construct(
43+
Template\Context $context,
44+
SuggestedQueriesInterface $searchDataProvider,
45+
QueryFactoryInterface $queryFactory,
46+
$title,
47+
array $data = []
48+
) {
49+
$this->searchDataProvider = $searchDataProvider;
50+
$this->query = $queryFactory->get();
51+
$this->title = $title;
52+
parent::__construct($context, $data);
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
public function getItems()
59+
{
60+
return $this->searchDataProvider->getItems($this->query);
61+
}
62+
63+
/**
64+
* {@inheritdoc}
65+
*/
66+
public function isShowResultsCount()
67+
{
68+
return $this->searchDataProvider->isResultsCountEnabled();
69+
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public function getLink($queryText)
75+
{
76+
return $this->getUrl('*/*/') . '?q=' . urlencode($queryText);
77+
}
78+
79+
/**
80+
* {@inheritdoc}
81+
*/
82+
public function getTitle()
83+
{
84+
return __($this->title);
85+
}
86+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block;
7+
8+
/**
9+
* Interface \Magento\AdvancedSearch\Block\SearchDataInterface
10+
*
11+
*/
12+
interface SearchDataInterface
13+
{
14+
/**
15+
* Retrieve search suggestions
16+
*
17+
* @return array
18+
*/
19+
public function getItems();
20+
21+
/**
22+
* @return bool
23+
*/
24+
public function isShowResultsCount();
25+
26+
/**
27+
* @param string $queryText
28+
* @return string
29+
*/
30+
public function getLink($queryText);
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getTitle();
36+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdvancedSearch\Block;
7+
8+
/**
9+
* @api
10+
* @since 100.0.2
11+
*/
12+
class Suggestions extends SearchData
13+
{
14+
}

0 commit comments

Comments
 (0)