Skip to content

Commit 8df4edc

Browse files
committed
Merge branch 'MAGETWO-98825' of https://github.com/magento-tango/magento2ce into pr_2019_07_12
2 parents 8f8f105 + 0ff0efe commit 8df4edc

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model\Category;
9+
10+
use Magento\Catalog\Api\CategoryRepositoryInterface;
11+
use Magento\Catalog\Model\Category;
12+
use Magento\Store\Api\GroupRepositoryInterface;
13+
14+
/**
15+
* Fetcher for associated with store group categories.
16+
*/
17+
class StoreCategories
18+
{
19+
/**
20+
* @var CategoryRepositoryInterface
21+
*/
22+
private $categoryRepository;
23+
24+
/**
25+
* @var GroupRepositoryInterface
26+
*/
27+
private $groupRepository;
28+
29+
/**
30+
* @param CategoryRepositoryInterface $categoryRepository
31+
* @param GroupRepositoryInterface $groupRepository
32+
*/
33+
public function __construct(
34+
CategoryRepositoryInterface $categoryRepository,
35+
GroupRepositoryInterface $groupRepository
36+
) {
37+
$this->categoryRepository = $categoryRepository;
38+
$this->groupRepository = $groupRepository;
39+
}
40+
41+
/**
42+
* Get all category ids for store.
43+
*
44+
* @param int|null $storeGroupId
45+
* @return int[]
46+
* @throws \Magento\Framework\Exception\NoSuchEntityException
47+
*/
48+
public function getCategoryIds(?int $storeGroupId = null): array
49+
{
50+
$rootCategoryId = $storeGroupId
51+
? $this->groupRepository->get($storeGroupId)->getRootCategoryId()
52+
: Category::TREE_ROOT_ID;
53+
/** @var Category $rootCategory */
54+
$rootCategory = $this->categoryRepository->get($rootCategoryId);
55+
$categoriesIds = array_map(
56+
function ($value) {
57+
return (int) $value;
58+
},
59+
(array) $rootCategory->getAllChildren(true)
60+
);
61+
62+
return $categoriesIds;
63+
}
64+
}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ private function getField(string $sectionId, string $groupId, string $fieldId):
287287
*
288288
* @param Field $field
289289
* @param string $fieldId Need for support of clone_field feature
290-
* @param array &$oldConfig Need for compatibility with _processGroup()
291-
* @param array &$extraOldGroups Need for compatibility with _processGroup()
290+
* @param array $oldConfig Need for compatibility with _processGroup()
291+
* @param array $extraOldGroups Need for compatibility with _processGroup()
292292
* @return string
293293
*/
294294
private function getFieldPath(Field $field, string $fieldId, array &$oldConfig, array &$extraOldGroups): string
@@ -337,8 +337,8 @@ private function isValueChanged(array $oldConfig, string $path, array $fieldData
337337
* @param string $sectionId
338338
* @param string $groupId
339339
* @param array $groupData
340-
* @param array &$oldConfig
341-
* @param array &$extraOldGroups
340+
* @param array $oldConfig
341+
* @param array $extraOldGroups
342342
* @return array
343343
*/
344344
private function getChangedPaths(
@@ -384,8 +384,8 @@ private function getChangedPaths(
384384
* @param array $groupData
385385
* @param array $groups
386386
* @param string $sectionPath
387-
* @param array &$extraOldGroups
388-
* @param array &$oldConfig
387+
* @param array $extraOldGroups
388+
* @param array $oldConfig
389389
* @param \Magento\Framework\DB\Transaction $saveTransaction
390390
* @param \Magento\Framework\DB\Transaction $deleteTransaction
391391
* @return void
@@ -546,6 +546,8 @@ public function setDataByPath($path, $value)
546546
}
547547

548548
$section = array_shift($pathParts);
549+
$this->setData('section', $section);
550+
549551
$data = [
550552
'fields' => [
551553
array_pop($pathParts) => ['value' => $value],
@@ -558,8 +560,8 @@ public function setDataByPath($path, $value)
558560
],
559561
];
560562
}
561-
$data['section'] = $section;
562-
$this->addData($data);
563+
$groups = array_replace_recursive((array) $this->getData('groups'), $data['groups']);
564+
$this->setData('groups', $groups);
563565
}
564566

565567
/**
@@ -679,7 +681,7 @@ protected function _checkSingleStoreMode(
679681
* Get config data value
680682
*
681683
* @param string $path
682-
* @param null|bool &$inherit
684+
* @param null|bool $inherit
683685
* @param null|array $configData
684686
* @return \Magento\Framework\Simplexml\Element
685687
*/

0 commit comments

Comments
 (0)