Advertisement
ales_cankar

Untitled

Jun 12th, 2018
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?php
  2.  
  3. $skip = [
  4.     'customer/address_templates/html',
  5.     // add any config paths you might want to avoid importing
  6. ];
  7.  
  8. $config = include './config_backup.php';  // this is the dumped config backup
  9. $i = 0;
  10. echo "<pre>";
  11. foreach ($config['system'] as $l0 => $l0items) {
  12.     if ($l0 == 'default') {
  13.         foreach ($l0items as $l1 => $l1items) {
  14.             foreach ($l1items as $l2 => $l2items) {
  15.                 if (!is_array($l2items)) { continue; }
  16.                 foreach ($l2items as $key => $value) {
  17.                     if (in_array("$l1/$l2/$key", $skip)) {
  18.                         continue;
  19.                     }
  20.                     $buffer = "bin/magento config:set $l1/$l2/$key";
  21.                     if (is_string($value)) {
  22.                         $buffer .= ' "' . str_replace('"', '\"', $value) . '";';
  23.                         echo '<br />echo "#'.$i++.' - Setting : ' . $l1.'/'.$l2.'/'.$key.'";<br />';
  24.                         echo $buffer;
  25.                     } else {
  26.                         continue;
  27.                     }
  28.                 }
  29.             }
  30.         }
  31.     } else {
  32.         foreach ($l0items as $scope => $items) {
  33.             if (in_array($scope, ['admin', 'default'])) {
  34.                 continue;
  35.             }
  36.             foreach ($items as $l1 => $l1items) {
  37.                 foreach ($l1items as $l2 => $l2items) {
  38.                     if (!is_array($l2items)) { continue; }
  39.                     foreach ($l2items as $key => $value) {
  40.                         if (in_array("$l1/$l2/$key", $skip)) {
  41.                             continue;
  42.                         }
  43.                         $buffer = "bin/magento config:set $l1/$l2/$key --scope website --scope-code $scope";
  44.                         if (is_string($value)) {
  45.                             $buffer .= ' "' . str_replace('"', '\"', $value) . '";';
  46.                             echo '<br />echo "#'.$i++.' - Setting : ' . $l1.'/'.$l2.'/'.$key.' for website ' . $scope .'";<br />';
  47.                             echo $buffer;
  48.                         } else {
  49.                             continue;
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56. }
  57. echo "</pre>";
  58.  
  59. ?>
  60. <style>
  61.     pre  {
  62.         background : #ddd;
  63.         padding : 20px 40px;
  64.     }
  65. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement