Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor level to hierarchy #6307

Open
wants to merge 1 commit into
base: 4.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config/eccube/packages/eccube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Controller/Admin/Product/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
12 changes: 6 additions & 6 deletions src/Eccube/Controller/Admin/Product/CsvImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,24 +811,24 @@
}
$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['階層']);

Check warning on line 821 in src/Eccube/Controller/Admin/Product/CsvImportController.php

View check run for this annotation

Codecov / codecov/patch

src/Eccube/Controller/Admin/Product/CsvImportController.php#L821

Added line #L821 was not covered by tests
} 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);
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/doctrine/import_csv/ja/dtb_csv.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/Eccube/Resource/template/admin/Product/category.twig
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ file that was distributed with this source code.
<form role="form" name="form1" id="form1" method="post"
action="{% if TargetCategory.id %}{{ path('admin_product_category_edit', {id: TargetCategory.id}) }}{% elseif Parent %}{{ url('admin_product_category_show', {'parent_id': Parent.id}) }}{% else %}{{ url('admin_product_category') }}{% endif %}"
enctype="multipart/form-data">
{% if TargetCategory.hierarchy <= eccube_config.eccube_category_nest_level %}
{% if TargetCategory.hierarchy <= eccube_config.eccube_category_nest_hierarchy %}
{{ form_widget(form._token) }}
<div class="row mb-3">
<div class="col-auto">
Expand Down Expand Up @@ -312,9 +312,9 @@ file that was distributed with this source code.
</div>
</div>

{% macro tree(Category, TargetId, level, Ids) %}
{% macro tree(Category, TargetId, hierarchy, Ids) %}
{% import _self as selfMacro %}
{% set level = level + 1 %}
{% set hierarchy = hierarchy + 1 %}
<li>
<label {% if (Category.children|length > 0) and (Category.id not in Ids) %}class="collapsed"
{% endif %}data-bs-toggle="collapse"
Expand All @@ -328,7 +328,7 @@ file that was distributed with this source code.
<ul class="collapse list-unstyled {% if Category.id in Ids %}show{% endif %}"
id="directory_category{{ Category.id }}">
{% for ChildCategory in Category.children %}
{{ selfMacro.tree(ChildCategory, TargetId, level, Ids) }}
{{ selfMacro.tree(ChildCategory, TargetId, hierarchy, Ids) }}
{% endfor %}
</ul>
{% endif %}
Expand Down
Loading