Back-in-stock notifications not sent for attribute combinations with multiple warehouses
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C#
- Stars
- 1.3k
- Forks
- 549
- Avg merge
- 7h 58m
- Merged PRs (30d)
- 52
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from grandnode/grandnode2
-
HTML sitemap lists unpublished pagesPossibly taken @KrzysztofPajak claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grandnode/grandnode2#883 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
grandnode/grandnode2#880 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
grandnode/grandnode2#849 ·
Maintainers usually reply within 1 day
-
grandnode/grandnode2#499 ·
Maintainers usually reply within 1 day
-
grandnode/grandnode2#410 ·
Maintainers usually reply within 1 day
All issues in grandnode/grandnode2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stryker-mutator/stryker-net#3892 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
MobiFlight/MobiFlight-Connector#3419 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Kryptos-FR/MarkView.Avalonia#105 ·
Maintainers usually reply within 1 day
-
[辞書]Open提案 辞書
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/fluentui-blazor#5410 ·
Maintainers usually reply within 1 day