EC-CUBE / EC-CUBE/ec-cube

複製した商品の規格を初期化・再登録すると空の規格が生成される

Open
#5,040 7 comments 0 reactions 0 assignees View on GitHub
bug:Middle
Dominant language
PHP
Stars
788
Forks
719
Avg merge
3d 20h
Merged PRs (30d)
45

Description

## 概要(Overview)

商品複製後、規格の初期化・再登録を行うと空の規格が生成される

![image](https://user-images.githubusercontent.com/8196725/117918866-e2322b80-b326-11eb-9a51-36a604edd83e.png)

## 再現手順(Procedure)

- 規格ありの商品Aを登録
- 商品Aを複製し、商品Bを作成
- 商品Bの規格を初期化し、規格を再登録する

## データの推移

```
# 商品Aのデータ
eccube_db=# select id, product_id, class_category_id1, class_category_id2, price01, price02,visible from dtb_product_class where product_id = 8;
id | product_id | class_category_id1 | class_category_id2 | price01 | price02 | visible
----+------------+--------------------+--------------------+---------+---------+---------
76 | 8 | 4 | | 100.00 | 100.00 | t
77 | 8 | 5 | | 100.00 | 100.00 | t
78 | 8 | 6 | | 100.00 | 100.00 | t
75 | 8 | | | | 400.00 | f

# 複製した商品Bのデータ
eccube_db=# select id, product_id, class_category_id1, class_category_id2, price01, price02,visible from dtb_product_class where product_id = 9;
id | product_id | class_category_id1 | class_category_id2 | price01 | price02 | visible
----+------------+--------------------+--------------------+---------+---------+---------
79 | 9 | 4 | | 100.00 | 100.00 | t
80 | 9 | 5 | | 100.00 | 100.00 | t
81 | 9 | 6 | | 100.00 | 100.00 | t
82 | 9 | | | | 400.00 | f ★
83 | 9 | | | | 400.00 | f ★

★規格初期化用のレコードが増える

# 商品Bの規格を初期化
eccube_db=# select id, product_id, class_category_id1, class_category_id2, price01, price02,visible from dtb_product_class where product_id = 9;
id | product_id | class_category_id1 | class_category_id2 | price01 | price02 | visible
----+------------+--------------------+--------------------+---------+---------+---------
83 | 9 | | | | 400.00 | f ★
79 | 9 | 4 | | 100.00 | 100.00 | f
80 | 9 | 5 | | 100.00 | 100.00 | f
81 | 9 | 6 | | 100.00 | 100.00 | f
82 | 9 | | | | 400.00 | t ★

★規格初期化用のレコードの一つがvisible=trueになり(これは正常)、もう一つはfalseのままで残る

# 商品Bの規格を再登録
eccube_db=# select id, product_id, class_category_id1, class_category_id2, price01, price02,visible from dtb_product_class where product_id = 9;
id | product_id | class_category_id1 | class_category_id2 | price01 | price02 | visible
----+------------+--------------------+--------------------+---------+---------+---------
83 | 9 | | | | 400.00 | f
82 | 9 | | | | 400.00 | t ★
79 | 9 | 4 | | 200.00 | 200.00 | t
80 | 9 | 5 | | 200.00 | 200.00 | t
81 | 9 | 6 | | 200.00 | 200.00 | t

★規格初期化用レコードがvisible=trueのまま残存し、このデータが画面上に表示される
```

商品複製時に、規格初期化用レコードが増殖し、その結果再登録時に不要なデータが残るのが原因と思われる

### 環境 (environment)
+ EC-CUBE: 4.0.x
+ PHP: 7.x.x
+ DB:
- PostgreSQL x.x.x
- MySQL x.x.x

## 関連情報 (Ref)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the product duplication, specification reset, and re-registration flow described in the issue, then inspect dtb_product_class records for duplicate initialization rows and their visible values. Done means duplication does not create extra initialization records, and resetting and re-registering specifications leaves no unwanted visible empty specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.