-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.3-develop' of https://github.com/magento/magento2 int…
…o 2.3-develop
- Loading branch information
Showing
247 changed files
with
24,768 additions
and
1,178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/code/Magento/AdvancedSearch/Block/Adminhtml/Search/Edit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block\Adminhtml\Search; | ||
|
||
/** | ||
* Search queries relations grid container | ||
* | ||
* @api | ||
* @author Magento Core Team <[email protected]> | ||
* @since 100.0.2 | ||
*/ | ||
class Edit extends \Magento\Backend\Block\Widget\Grid\Container | ||
{ | ||
/** | ||
* Enable grid container | ||
* | ||
* @return void | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->_blockGroup = 'Magento_AdvancedSearch'; | ||
$this->_controller = 'adminhtml_search'; | ||
$this->_headerText = __('Related Search Terms'); | ||
$this->_addButtonLabel = __('Add New Search Term'); | ||
parent::_construct(); | ||
$this->buttonList->remove('add'); | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
app/code/Magento/AdvancedSearch/Block/Adminhtml/Search/Grid.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block\Adminhtml\Search; | ||
|
||
/** | ||
* Search query relations edit grid | ||
* | ||
* @api | ||
* @author Magento Core Team <[email protected]> | ||
* @since 100.0.2 | ||
*/ | ||
class Grid extends \Magento\Backend\Block\Widget\Grid | ||
{ | ||
/** | ||
* @var \Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options | ||
*/ | ||
protected $_options; | ||
|
||
/** | ||
* @var \Magento\Framework\Registry | ||
*/ | ||
protected $_registryManager; | ||
|
||
/** | ||
* @var \Magento\Framework\Json\Helper\Data | ||
*/ | ||
protected $jsonHelper; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Backend\Helper\Data $backendHelper | ||
* @param \Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options $options | ||
* @param \Magento\Framework\Registry $registry | ||
* @param \Magento\Framework\Json\Helper\Data $jsonHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Backend\Helper\Data $backendHelper, | ||
\Magento\AdvancedSearch\Model\Adminhtml\Search\Grid\Options $options, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Framework\Json\Helper\Data $jsonHelper, | ||
array $data = [] | ||
) { | ||
$this->jsonHelper = $jsonHelper; | ||
parent::__construct($context, $backendHelper, $data); | ||
$this->_options = $options; | ||
$this->_registryManager = $registry; | ||
$this->setDefaultFilter(['query_id_selected' => 1]); | ||
} | ||
|
||
/** | ||
* Retrieve a value from registry by a key | ||
* | ||
* @return mixed | ||
*/ | ||
public function getQuery() | ||
{ | ||
return $this->_registryManager->registry('current_catalog_search'); | ||
} | ||
|
||
/** | ||
* Add column filter to collection | ||
* | ||
* @param \Magento\Backend\Block\Widget\Grid\Column $column | ||
* @return $this | ||
*/ | ||
protected function _addColumnFilterToCollection($column) | ||
{ | ||
// Set custom filter for query selected flag | ||
if ($column->getId() == 'query_id_selected' && $this->getQuery()->getId()) { | ||
$selectedIds = $this->getSelectedQueries(); | ||
if (empty($selectedIds)) { | ||
$selectedIds = 0; | ||
} | ||
if ($column->getFilter()->getValue()) { | ||
$this->getCollection()->addFieldToFilter('query_id', ['in' => $selectedIds]); | ||
} elseif (!empty($selectedIds)) { | ||
$this->getCollection()->addFieldToFilter('query_id', ['nin' => $selectedIds]); | ||
} | ||
} else { | ||
parent::_addColumnFilterToCollection($column); | ||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve selected related queries from grid | ||
* | ||
* @return array | ||
*/ | ||
public function getSelectedQueries() | ||
{ | ||
return $this->_options->toOptionArray(); | ||
} | ||
|
||
/** | ||
* Get queries json | ||
* | ||
* @return string | ||
*/ | ||
public function getQueriesJson() | ||
{ | ||
$queries = array_flip($this->getSelectedQueries()); | ||
if (!empty($queries)) { | ||
return $this->jsonHelper->jsonEncode($queries); | ||
} | ||
return '{}'; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
app/code/Magento/AdvancedSearch/Block/Adminhtml/System/Config/TestConnection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block\Adminhtml\System\Config; | ||
|
||
/** | ||
* Search engine test connection block | ||
* @api | ||
* @since 100.1.0 | ||
*/ | ||
class TestConnection extends \Magento\Config\Block\System\Config\Form\Field | ||
{ | ||
/** | ||
* Set template to itself | ||
* | ||
* @return $this | ||
* @since 100.1.0 | ||
*/ | ||
protected function _prepareLayout() | ||
{ | ||
parent::_prepareLayout(); | ||
$this->setTemplate('Magento_AdvancedSearch::system/config/testconnection.phtml'); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Unset some non-related element parameters | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
* @since 100.1.0 | ||
*/ | ||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$element = clone $element; | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
return parent::render($element); | ||
} | ||
|
||
/** | ||
* Get the button and scripts contents | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
* @since 100.1.0 | ||
*/ | ||
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$originalData = $element->getOriginalData(); | ||
$this->addData( | ||
[ | ||
'button_label' => __($originalData['button_label']), | ||
'html_id' => $element->getHtmlId(), | ||
'ajax_url' => $this->_urlBuilder->getUrl('catalog/search_system_config/testconnection'), | ||
'field_mapping' => str_replace('"', '\\"', json_encode($this->_getFieldMapping())) | ||
] | ||
); | ||
|
||
return $this->_toHtml(); | ||
} | ||
|
||
/** | ||
* Returns configuration fields required to perform the ping request | ||
* | ||
* @return array | ||
* @since 100.1.0 | ||
*/ | ||
protected function _getFieldMapping() | ||
{ | ||
return ['engine' => 'catalog_search_engine']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block; | ||
|
||
/** | ||
* @api | ||
* @since 100.0.2 | ||
*/ | ||
class Recommendations extends SearchData | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Search\Model\QueryFactoryInterface; | ||
use Magento\Search\Model\QueryInterface; | ||
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface; | ||
|
||
abstract class SearchData extends Template implements SearchDataInterface | ||
{ | ||
/** | ||
* @var QueryInterface | ||
*/ | ||
private $query; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $title; | ||
|
||
/** | ||
* @var SuggestedQueriesInterface | ||
*/ | ||
private $searchDataProvider; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'search_data.phtml'; | ||
|
||
/** | ||
* @param Template\Context $context | ||
* @param SuggestedQueriesInterface $searchDataProvider | ||
* @param QueryFactoryInterface $queryFactory | ||
* @param string $title | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Template\Context $context, | ||
SuggestedQueriesInterface $searchDataProvider, | ||
QueryFactoryInterface $queryFactory, | ||
$title, | ||
array $data = [] | ||
) { | ||
$this->searchDataProvider = $searchDataProvider; | ||
$this->query = $queryFactory->get(); | ||
$this->title = $title; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getItems() | ||
{ | ||
return $this->searchDataProvider->getItems($this->query); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isShowResultsCount() | ||
{ | ||
return $this->searchDataProvider->isResultsCountEnabled(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getLink($queryText) | ||
{ | ||
return $this->getUrl('*/*/') . '?q=' . urlencode($queryText); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTitle() | ||
{ | ||
return __($this->title); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/code/Magento/AdvancedSearch/Block/SearchDataInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block; | ||
|
||
/** | ||
* Interface \Magento\AdvancedSearch\Block\SearchDataInterface | ||
* | ||
*/ | ||
interface SearchDataInterface | ||
{ | ||
/** | ||
* Retrieve search suggestions | ||
* | ||
* @return array | ||
*/ | ||
public function getItems(); | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isShowResultsCount(); | ||
|
||
/** | ||
* @param string $queryText | ||
* @return string | ||
*/ | ||
public function getLink($queryText); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTitle(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AdvancedSearch\Block; | ||
|
||
/** | ||
* @api | ||
* @since 100.0.2 | ||
*/ | ||
class Suggestions extends SearchData | ||
{ | ||
} |
Oops, something went wrong.