Back-in-stock notifications not sent for attribute combinations with multiple warehouses
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 65/100
调研方向
Start with src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs, especially InsertOrUpdateProductAttributeCombinationPopup and PrepareCombinationWarehouseInventory, then inspect ProductAttributeCombination.Clone() in src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs and the multi-warehouse branch of OutOfStockNotifications. Add a unit test for editing a combination's warehouse stock from zero to positive with a subscriber; done means a notification is queued and the existing single-warehouse behavior remains unaffected.
由索引模型根据 Issue 内容生成。
描述
Description
When a product uses stock management by attribute combinations with multiple warehouses, raising the stock of a combination's warehouse in the admin panel does not send back-in-stock notifications to subscribers.
Steps to reproduce
- Create a product, published, with
Manage inventory method = Manage stock by attributes,Use multiple warehousesenabled,Allow out of stock subscriptionsenabled andBackorders = No backorders. - Add an attribute combination with warehouse stock 0 in one warehouse.
- As a customer, subscribe to the "notify me when available" for that combination.
- In admin, edit the combination (edit popup) and raise that warehouse's stock above 0.
- No notification is queued for the subscriber.
Cause
ProductViewModelService.InsertOrUpdateProductAttributeCombinationPopup (src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs, ~line 2239) snapshots the previous state with combination.Clone(). ProductAttributeCombination.Clone() (src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs, line 87) is MemberwiseClone(), a shallow copy, so the WarehouseInventory list and its items are shared between the clone and the original.
PrepareCombinationWarehouseInventory (~line 2088) then modifies those shared ProductCombinationWarehouseInventory items in place (existingPwI.StockQuantity = ..., and Add/Remove on the shared list). When OutOfStockNotifications(product, combination, prevCombination) runs (~line 223), the multi-warehouse branch compares prevcombination.WarehouseInventory with combination.WarehouseInventory, which are the same objects, so "previously out of stock, now in stock" is never detected, both for the per-warehouse check and for the total-sum check.
The single-warehouse branch is not affected, since StockQuantity is a value type copied by the clone. The product-level path is not affected either: it snapshots prevMultiWarehouseStock into new ProductWarehouseInventory objects (~line 781).
Suggested fix
Deep-copy WarehouseInventory when snapshotting the previous state (e.g. in Clone() or in the service, create new ProductCombinationWarehouseInventory items with WarehouseId, StockQuantity, ReservedQuantity), or capture the previous per-warehouse quantities before PrepareCombinationWarehouseInventory mutates them. A unit test for the combination edit path with multiple warehouses would cover this.
Notes
Related: #880 (journaling manual stock changes), which touches the same manual stock edit flow.
- 主要语言
- C#
- 星标
- 1.3k
- 派生
- 549
- 平均合并
- 8 小时 14 分钟
- 30 天内合并 PR
- 53
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
grandnode/grandnode2 的其他 Issue
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
grandnode/grandnode2#880 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
grandnode/grandnode2#849 ·
维护者通常 1 天内回复
-
grandnode/grandnode2#499 ·
维护者通常 1 天内回复
-
grandnode/grandnode2#410 ·
维护者通常 1 天内回复
-
grandnode/grandnode2#396 ·
维护者通常 1 天内回复
查看 grandnode/grandnode2 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
PCL-Community/PCL-CE#3658 ·
维护者通常 1 天内回复
-
Deploy & Patch-issues opprettes ikke: create-pnd-issues.yml har feilet hver uke siden 2025-09-08未关闭
难度 2/5 1-3 小时 新手友好度 62/100
Altinn/altinn-auth#4359 ·
维护者通常 1 天内回复
-
アプリ: チャット 優先: 中 提案
难度 2/5 1-3 小时 新手友好度 70/100
yksr-melt/Meltype#243 · 1 条评论 ·
维护者通常 1 天内回复
-
bug core
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
type/automation type/tech-debt
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复