Skip to content

Commit 7882b71

Browse files
committed
MAGETWO-97247: Impossible to enable shared catalog through cli command
1 parent 54a3590 commit 7882b71

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

app/code/Magento/Config/Model/Config.php

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -552,27 +552,11 @@ private function initScope()
552552
$this->setSection('');
553553
}
554554

555-
if (!$this->getScope()) {
556-
switch (true) {
557-
case $this->getStore():
558-
$this->setScope(StoreScopeInterface::SCOPE_STORES);
559-
$this->setScopeCode($this->getStore());
560-
break;
561-
case $this->getWebsite():
562-
$this->setScope(StoreScopeInterface::SCOPE_WEBSITES);
563-
$this->setScopeCode($this->getWebsite());
564-
break;
565-
default:
566-
$this->setScope(ScopeInterface::SCOPE_DEFAULT);
567-
$this->setScopeCode('');
568-
break;
569-
}
570-
}
571-
$scope = $this->scopeResolverPool->get($this->getScope())
572-
->getScope($this->getScopeCode());
555+
$scope = $this->retrieveScope();
573556
$this->setScope($this->scopeTypeNormalizer->normalize($scope->getScopeType()));
574557
$this->setScopeCode($scope->getCode());
575558
$this->setScopeId($scope->getId());
559+
576560
if ($this->getWebsite() === null) {
577561
$this->setWebsite(StoreScopeInterface::SCOPE_WEBSITES === $this->getScope() ? $scope->getId() : '');
578562
}
@@ -581,6 +565,54 @@ private function initScope()
581565
}
582566
}
583567

568+
/**
569+
* Retrieve scope from initial data
570+
*
571+
* @return ScopeInterface
572+
*/
573+
private function retrieveScope(): ScopeInterface
574+
{
575+
$scopeType = $this->getScope();
576+
if (!$scopeType) {
577+
switch (true) {
578+
case $this->getStore():
579+
$scopeType = StoreScopeInterface::SCOPE_STORES;
580+
$scopeIdentifier = $this->getStore();
581+
break;
582+
case $this->getWebsite():
583+
$scopeType = StoreScopeInterface::SCOPE_WEBSITES;
584+
$scopeIdentifier = $this->getWebsite();
585+
break;
586+
default:
587+
$scopeType = ScopeInterface::SCOPE_DEFAULT;
588+
$scopeIdentifier = null;
589+
break;
590+
}
591+
} else {
592+
switch (true) {
593+
case $this->getScopeId() !== null:
594+
$scopeIdentifier = $this->getScopeId();
595+
break;
596+
case $this->getScopeCode() !== null:
597+
$scopeIdentifier = $this->getScopeCode();
598+
break;
599+
case $this->getStore() !== null:
600+
$scopeIdentifier = $this->getStore();
601+
break;
602+
case $this->getWebsite() !== null:
603+
$scopeIdentifier = $this->getWebsite();
604+
break;
605+
default:
606+
$scopeIdentifier = null;
607+
break;
608+
}
609+
}
610+
$scope = $this->scopeResolverPool->get($scopeType)
611+
->getScope($scopeIdentifier);
612+
613+
return $scope;
614+
}
615+
584616
/**
585617
* Return formatted config data for current section
586618
*

app/code/Magento/Paypal/Model/Config/Structure/Element/FieldPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(RequestInterface $request)
3636
*/
3737
public function afterGetConfigPath(FieldConfigStructure $subject, $result)
3838
{
39-
if (!$result && $this->request->getParam('section') == 'payment') {
39+
if (!$result && strpos($subject->getPath(), 'payment_') === 0) {
4040
$result = preg_replace(
4141
'@^(' . implode('|', ConfigStructurePlugin::getPaypalConfigCountries(true)) . ')/@',
4242
'payment/',

0 commit comments

Comments
 (0)