From d4c2dcd61c4bf0cc532108fa3af5995514305b43 Mon Sep 17 00:00:00 2001 From: daichi_otani Date: Fri, 15 Nov 2024 14:40:29 +0900 Subject: [PATCH] refactor level to hierarchy --- app/config/eccube/packages/eccube.yaml | 2 +- .../Controller/Admin/Product/CategoryController.php | 2 +- .../Controller/Admin/Product/CsvImportController.php | 12 ++++++------ .../Resource/doctrine/import_csv/ja/dtb_csv.csv | 2 +- .../Resource/template/admin/Product/category.twig | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/config/eccube/packages/eccube.yaml b/app/config/eccube/packages/eccube.yaml index 0b4a38f45d5..97fcac016af 100644 --- a/app/config/eccube/packages/eccube.yaml +++ b/app/config/eccube/packages/eccube.yaml @@ -61,7 +61,7 @@ parameters: eccube_id_max_len: 50 eccube_id_min_len: 4 eccube_int_len: 9 # 最大値で制御したい - eccube_category_nest_level: 5 + eccube_category_nest_hierarchy: 5 eccube_lltext_len: 99999 eccube_ltext_len: 3000 eccube_max_total_fee: 9999999999 diff --git a/src/Eccube/Controller/Admin/Product/CategoryController.php b/src/Eccube/Controller/Admin/Product/CategoryController.php index 92da87d0161..62c62dd64cf 100644 --- a/src/Eccube/Controller/Admin/Product/CategoryController.php +++ b/src/Eccube/Controller/Admin/Product/CategoryController.php @@ -118,7 +118,7 @@ public function index(Request $request, CacheUtil $cacheUtil, $parent_id = null, if ($request->getMethod() === 'POST') { $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - if ($this->eccubeConfig['eccube_category_nest_level'] < $TargetCategory->getHierarchy()) { + if ($this->eccubeConfig['eccube_category_nest_hierarchy'] < $TargetCategory->getHierarchy()) { throw new BadRequestHttpException(); } log_info('カテゴリ登録開始', [$id]); diff --git a/src/Eccube/Controller/Admin/Product/CsvImportController.php b/src/Eccube/Controller/Admin/Product/CsvImportController.php index 4a763981d52..d023c6ae082 100644 --- a/src/Eccube/Controller/Admin/Product/CsvImportController.php +++ b/src/Eccube/Controller/Admin/Product/CsvImportController.php @@ -811,24 +811,24 @@ public function csvCategory(Request $request, CacheUtil $cacheUtil) } $Category->setParent($ParentCategory); - // Level + // hierarchy if (isset($row['階層']) && StringUtil::isNotBlank($row['階層'])) { if ($ParentCategory == null && $row['階層'] != 1) { $this->addErrors(($data->key() + 1).'行目の親カテゴリIDが存在しません。'); return $this->renderWithError($form, $headers); } - $level = StringUtil::trimAll($row['階層']); + $hierarchy = StringUtil::trimAll($row['階層']); } else { - $level = 1; + $hierarchy = 1; if ($ParentCategory) { - $level = $ParentCategory->getHierarchy() + 1; + $hierarchy = $ParentCategory->getHierarchy() + 1; } } - $Category->setHierarchy($level); + $Category->setHierarchy($hierarchy); - if ($this->eccubeConfig['eccube_category_nest_level'] < $Category->getHierarchy()) { + if ($this->eccubeConfig['eccube_category_nest_hierarchy'] < $Category->getHierarchy()) { $this->addErrors(($data->key() + 1).'行目のカテゴリが最大レベルを超えているため設定できません。'); return $this->renderWithError($form, $headers); diff --git a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_csv.csv b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_csv.csv index a91a0f717fa..104146a279a 100644 --- a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_csv.csv +++ b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_csv.csv @@ -199,7 +199,7 @@ "200","5",,"Eccube\\Entity\\Category","sort_no",,"表示ランク","2","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" "201","5",,"Eccube\\Entity\\Category","name",,"カテゴリ名","3","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" "202","5",,"Eccube\\Entity\\Category","Parent","id","親カテゴリID","4","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" -"203","5",,"Eccube\\Entity\\Category","level",,"階層","5","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" +"203","5",,"Eccube\\Entity\\Category","hierarchy",,"階層","5","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" "204","1",,"Eccube\\Entity\\ProductClass","TaxRule","tax_rate","税率","31","0","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" "205","2",,"Eccube\\Entity\\Customer","point",,"ポイント","33","1","2017-03-07 10:14:00","2017-03-07 10:14:00","csv" "206","1",,"Eccube\\Entity\\ProductClass","visible",,"商品規格表示フラグ","32","0","2022-11-24 00:00:00","2022-11-24 00:00:00","csv" diff --git a/src/Eccube/Resource/template/admin/Product/category.twig b/src/Eccube/Resource/template/admin/Product/category.twig index b143c98f3e6..bc1b740ce02 100644 --- a/src/Eccube/Resource/template/admin/Product/category.twig +++ b/src/Eccube/Resource/template/admin/Product/category.twig @@ -167,7 +167,7 @@ file that was distributed with this source code.
- {% if TargetCategory.hierarchy <= eccube_config.eccube_category_nest_level %} + {% if TargetCategory.hierarchy <= eccube_config.eccube_category_nest_hierarchy %} {{ form_widget(form._token) }}
@@ -312,9 +312,9 @@ file that was distributed with this source code.
- {% macro tree(Category, TargetId, level, Ids) %} + {% macro tree(Category, TargetId, hierarchy, Ids) %} {% import _self as selfMacro %} - {% set level = level + 1 %} + {% set hierarchy = hierarchy + 1 %}