Skip to content

Commit

Permalink
Merge branch '2.3-develop' of https://github.com/magento/magento2 int…
Browse files Browse the repository at this point in the history
…o 2.3-develop
  • Loading branch information
jonathanKingston committed Mar 19, 2018
2 parents b032bbc + dea8b32 commit e501f67
Show file tree
Hide file tree
Showing 247 changed files with 24,768 additions and 1,178 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ addons:
- magento2.travis
services:
- rabbitmq
- elasticsearch
language: php
php:
- 7.0
Expand Down Expand Up @@ -49,7 +50,9 @@ cache:
- $HOME/.nvm
- $HOME/node_modules
- $HOME/yarn.lock
before_install: ./dev/travis/before_install.sh
before_install:
- 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
- ./dev/travis/before_install.sh
install: composer install --no-interaction
before_script: ./dev/travis/before_script.sh
script:
Expand Down
31 changes: 31 additions & 0 deletions app/code/Magento/AdvancedSearch/Block/Adminhtml/Search/Edit.php
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 app/code/Magento/AdvancedSearch/Block/Adminhtml/Search/Grid.php
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 '{}';
}
}
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'];
}
}
14 changes: 14 additions & 0 deletions app/code/Magento/AdvancedSearch/Block/Recommendations.php
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
{
}
86 changes: 86 additions & 0 deletions app/code/Magento/AdvancedSearch/Block/SearchData.php
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 app/code/Magento/AdvancedSearch/Block/SearchDataInterface.php
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();
}
14 changes: 14 additions & 0 deletions app/code/Magento/AdvancedSearch/Block/Suggestions.php
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
{
}
Loading

0 comments on commit e501f67

Please sign in to comment.