diff --git a/Console/Command/Sync.php b/Console/Command/Sync.php
index 5787622..0f2040a 100644
--- a/Console/Command/Sync.php
+++ b/Console/Command/Sync.php
@@ -8,6 +8,8 @@
namespace Mygento\Configsync\Console\Command;
+use Magento\Store\Model\StoreManagerInterface;
+
class Sync extends \Symfony\Component\Console\Command\Command
{
private const DELETE = '%DELETE%';
@@ -27,17 +29,24 @@ class Sync extends \Symfony\Component\Console\Command\Command
*/
private $output;
+ /**
+ * @var StoreManagerInterface
+ */
+ private $storeManager;
+
/**
* @param \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configInterface
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
+ StoreManagerInterface $storeManager,
\Magento\Framework\App\Config\ConfigResource\ConfigInterface $configInterface,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
parent::__construct();
$this->configInterface = $configInterface;
$this->scopeConfig = $scopeConfig;
+ $this->storeManager = $storeManager;
}
/**
@@ -85,7 +94,7 @@ protected function execute(
$importedValues = 0;
foreach ($envData as $scopeKey => $data) {
- if (!preg_match('/^(default|(websites|stores)-\d+)$/', $scopeKey)) {
+ if (!preg_match('/^(default|(websites|stores)-\w+)$/', $scopeKey)) {
$this->diag('Skipped scope: ' . $scopeKey . '');
continue;
}
@@ -94,6 +103,21 @@ protected function execute(
$scope = $scopeKeyExtracted['scope'];
$scopeId = $scopeKeyExtracted['scopeId'];
+ try {
+ if (is_string($scopeId)) {
+ if ($scope === 'websites') {
+ $scopeId = $this->storeManager->getWebsite($scopeId)->getId();
+ }
+ if ($scope === 'stores') {
+ $scopeId = $this->storeManager->getStore($scopeId)->getId();
+ }
+ }
+ } catch (\Exception $e) {
+ $this->diag('' . $e->getMessage() . '');
+ continue;
+ }
+
+
$this->diag('Scope: ' . $scope . '>');
$this->diag('Scope Id: ' . $scopeId . '>');
$this->diag('');
@@ -105,7 +129,6 @@ protected function execute(
$this->diag('' . $e->getMessage() . '');
continue;
}
-
$this->diag('Path: ' . $path . '');
$this->diag('Current value: ' . $currentValue . '');
$this->diag('New value: ' . $newValue . '');
diff --git a/README.md b/README.md
index a8874c6..5f01d3a 100644
--- a/README.md
+++ b/README.md
@@ -28,12 +28,19 @@ For example:
web/secure/use_in_frontend: 1
stores-1:
web/secure/use_in_frontend: 0
+ websites-us:
+ web/secure/use_in_frontend: 1
+ stores-us:
+ web/secure/use_in_frontend: 0
Valid scope keys are:
- default
- stores-`$id`
- websites-`$id`
+or
+* stores-`$code`
+* websites-`$code`
Use `%DELETE%` to delete config path