Skip to content

Instantly share code, notes, and snippets.

@satishgumudavelli
Created July 11, 2022 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishgumudavelli/9852d7617bc720a2fd626dc37aa30fb8 to your computer and use it in GitHub Desktop.
Save satishgumudavelli/9852d7617bc720a2fd626dc37aa30fb8 to your computer and use it in GitHub Desktop.
<?php
/* Need to add this script and csv in var/shell folder */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '5G');
error_reporting(E_ALL);
set_time_limit(0);
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\ResourceModel\AttributeValue;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager;
require __DIR__ . '/../../app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
/*$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('adminhtml');*/
$scopeConfig = $obj->get(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$encryption = $obj->get(\Magento\Framework\Encryption\EncryptorInterface::class);
$reader = $obj->create(Magento\Config\Model\Config\Structure\Reader::class);
$structureData = $reader->read('adminhtml');
/*$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(print_r($structureData, true));*/
$data = $structureData['config']['system'];
$sectionList = [];
foreach ($data['sections'] as $sectionId => $section) {
if (array_key_exists('children', $section) && is_array($section['children'])) {
foreach ($section['children'] as $childId => $child) {
if (isset($child['children'])) {
foreach ($child['children'] as $fieldId => $field) {
if (isset($field['backend_model']) && $field['backend_model'] == 'Magento\Config\Model\Config\Backend\Encrypted') {
$config_name = $sectionId . '/' . $childId . "/" . $fieldId;
$value = $scopeConfig->getValue($config_name);
if ($value) {
$sectionList[$config_name] = ['orig' => $value, 'encrypted' => $value ? $encryption->decrypt($value) : $value];
}
}
}
}
}
}
}
print_r($sectionList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment