Skip to content

Commit

Permalink
Merge branch '2.5.x' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Jul 17, 2018
2 parents 5588d97 + 9decad3 commit 17f1dd5
Showing 1 changed file with 40 additions and 2 deletions.
Expand Up @@ -12,6 +12,8 @@
*/
namespace Smile\ElasticsuiteCore\Model\ResourceModel\Search\Request;

use \Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Relevance Configuration Resource model
*
Expand All @@ -33,7 +35,33 @@ class RelevanceConfig extends \Magento\Config\Model\ResourceModel\Config
*/
public function saveConfig($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = 'default')
{
return parent::saveConfig($path, $value, $scope, $scopeCode);
$connection = $this->getConnection();
$select = $connection->select()->from(
$this->getMainTable()
)->where(
'path = ?',
$path
)->where(
'scope = ?',
$scope
)->where(
'scope_code = ?',
$scopeCode
);
$row = $connection->fetchRow($select);

$newData = ['scope' => $scope, 'scope_code' => $scopeCode, 'path' => $path, 'value' => $value];

if ($row) {
$whereCondition = [$this->getIdFieldName() . '=?' => $row[$this->getIdFieldName()]];
$connection->update($this->getMainTable(), $newData, $whereCondition);

return $this;
}

$connection->insert($this->getMainTable(), $newData);

return $this;
}

/**
Expand All @@ -47,7 +75,17 @@ public function saveConfig($path, $value, $scope = ScopeConfigInterface::SCOPE_T
*/
public function deleteConfig($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = 'default')
{
return parent::deleteConfig($path, $scope, $scopeCode);
$connection = $this->getConnection();
$connection->delete(
$this->getMainTable(),
[
$connection->quoteInto('path = ?', $path),
$connection->quoteInto('scope = ?', $scope),
$connection->quoteInto('scope_code = ?', $scopeCode),
]
);

return $this;
}

/**
Expand Down

0 comments on commit 17f1dd5

Please sign in to comment.