diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index 9cc7b792e67..f15d24b320f 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -1698,6 +1698,21 @@ public function deleteConfig($path, $scope = 'default', $scopeId = 0) return $this; } + + /** + * Get config value from DB + * + * @param string $path + * @param string $scope + * @param int $scopeId + * @return string|false + */ + public function getConfig(string $path, string $scope = 'default', int $scopeId = 0) + { + $resource = $this->getResourceModel(); + return $resource->getConfig(rtrim($path, '/'), $scope, $scopeId); + } + /** * Get fieldset from configuration * diff --git a/app/code/core/Mage/Core/Model/Resource/Config.php b/app/code/core/Mage/Core/Model/Resource/Config.php index 9d84c959021..6a3271fd7be 100644 --- a/app/code/core/Mage/Core/Model/Resource/Config.php +++ b/app/code/core/Mage/Core/Model/Resource/Config.php @@ -216,7 +216,7 @@ public function deleteConfig($path, $scope, $scopeId) * @param int $scopeId * @return string|false */ - public function getValue(string $path, string $scope = 'default', int $scopeId = 0) + public function getConfig(string $path, string $scope, int $scopeId) { $readAdapter = $this->_getReadAdapter(); $select = $readAdapter->select() diff --git a/dev/tests/unit/Mage/Core/Model/ConfigTest.php b/dev/tests/unit/Mage/Core/Model/ConfigTest.php new file mode 100644 index 00000000000..146ca0a2d9b --- /dev/null +++ b/dev/tests/unit/Mage/Core/Model/ConfigTest.php @@ -0,0 +1,37 @@ +subject = Mage::getModel('core/config'); + } + + public function testSaveDeleteGetConfig(): void + { + $path = 'test/config'; + $value = 'foo'; + + $this->assertFalse($this->subject->getConfig($path)); + + $this->subject->saveConfig($path, $value); + $this->assertEquals($value, $this->subject->getConfig($path)); + + $this->subject->deleteConfig($path); + $this->assertFalse($this->subject->getConfig($path)); + } +}