Back-in-stock notifications not sent for attribute combinations with multiple warehouses
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C#
- Star
- 1.3k
- Fork
- 549
- Merge trung bình
- 8 giờ 14 phút
- Pull request đã merge (30 ngày)
- 53
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của grandnode/grandnode2
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
grandnode/grandnode2#880 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Please add the offer systemĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
grandnode/grandnode2#849 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
grandnode/grandnode2#499 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
grandnode/grandnode2#410 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
grandnode/grandnode2#396 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của grandnode/grandnode2
Issue tương tự
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Tool] DirectBenchĐang mởhas-image has-readme needs-attention new-tool repo-verified
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
shanselman/TinyToolTown#844 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
StoreImmediately test is flaky and fails on Linux and macOSCó thể đã có người làm @jcannon98188 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
area:frontend FE P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
klasolsson81/jobbliggaren#2067 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
grame-cncm/faust#1344 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày