Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Untrack docs/superpowers/ (now gitignored)

KrzysztofPajak613fa3569b3a
diff --git a/docs/superpowers/plans/2026-08-16-arch001-product-consolidation-phase1.md b/docs/superpowers/plans/2026-08-16-arch001-product-consolidation-phase1.md
deleted file mode 100644
index f507ce950..000000000
--- a/docs/superpowers/plans/2026-08-16-arch001-product-consolidation-phase1.md
+++ /dev/null
@@ -1,1529 +0,0 @@
-# ARCH-001 Product Consolidation — Phase 1 (Controller + Service) Implementation Plan
-
-> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. Tasks 8 and 10 are per-item checklists (one region / one method each) — when using subagent-driven-development, dispatch one subagent per checklist row, not one subagent for the whole task.
-
-**Goal:** Eliminate the three duplicated `ProductController` classes (Admin/Store/Vendor) and the two duplicated `ProductViewModelService` classes (AdminShared/Vendor) by consolidating the logic into `Grand.Web.AdminShared`, scoped per host through a new `IAdminDataScope<TEntity>` strategy, with each host reduced to a thin subclass — mirroring the existing `BaseLoginController` pattern.
-
-**Architecture:** A new `IAdminDataScope<TEntity>` (data filtering/access/default-value strategy) and a `ResourceKeyPrefix` (host-specific localization key prefix) are injected into a single `BaseProductController` and a single `ProductViewModelService`, both living in `Grand.Web.AdminShared`. Each host (`Grand.Web.Admin`, `Grand.Web.Store`, `Grand.Web.Vendor`) registers its own `IAdminDataScope<Product>` implementation and keeps only a ~20-line `ProductController : BaseProductController` subclass declaring `[Area(...)]`.
-
-**Tech Stack:** ASP.NET Core MVC, C# 13 primary constructors, MSTest + Moq (existing test stack per `.ai/knowledge/tests.md`), MongoDB repositories (unaffected — no data-layer changes in this plan).
-
-**Spec:** `docs/superpowers/specs/2026-08-16-arch001-product-consolidation-design.md`
-
-## Global Constraints
-
-- Do not merge the three hosts into one deployable app — separate auth models, data scopes, and independent deployability stay separate (spec, "Out of scope").
-- Direct migration, no feature flag / parallel-run — chosen deliberately because characterization tests already exist for all three `ProductController`s and both `ProductViewModelService`s (see Task 0).
-- `IAdminDataScope<TEntity>` ships only what `Product` needs (`HasAccess`, `ApplyScope`, `DefaultStoreId`) — no speculative members for entities not yet migrated.
-- Every host-specific literal (StaffStoreId access, `HasAccessToProduct`, `"Admin."`/`"Vendor."` resource-key prefixes) must route through `IAdminDataScope<Product>` or `ResourceKeyPrefix` — no residual host-specific `if` branches left inside `BaseProductController` or the shared service.
-- This plan is Phase 1 only (controller + service). Views (Phase 2) are a separate, later plan per the spec.
-- Follow existing repo conventions: primary-constructor DI (see `95c8548bf`), `.ai/standards/csharp-style.md`, `.ai/knowledge/mongodb.md` for any repository-layer touches (none expected in this plan).
-
----
-
-## Task 0: Baseline — confirm the safety net before touching anything
-
-**Files:**
-- Read only: `src/Tests/Grand.Web.Admin.Tests/Controllers/ProductControllerTests.cs`
-- Read only: `src/Tests/Grand.Web.Store.Tests/Controllers/ProductControllerTests.cs`
-- Read only: `src/Tests/Grand.Web.Vendor.Tests/Controllers/ProductControllerTests.cs`
-- Read only: `src/Tests/Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs`
-- Read only: `src/Tests/Grand.Web.Vendor.Tests/Services/ProductViewModelServiceTests.cs`
-
-**Interfaces:** none (read-only verification task).
-
-- [ ] **Step 1: Run all five existing test files and confirm they currently pass**
-
-Run:
-```
-dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~ProductController|FullyQualifiedName~ProductViewModelService"
-dotnet test src/Tests/Grand.Web.Store.Tests
-dotnet test src/Tests/Grand.Web.Vendor.Tests --filter "FullyQualifiedName~ProductController|FullyQualifiedName~ProductViewModelService"
-```
-Note: run `Grand.Web.Store.Tests` **unfiltered**, not with a `~ProductController` filter. `AutoMapperConfig` is a static singleton initialized in `PaymentControllerTests.TestInitialize` (`src/Tests/Grand.Web.Store.Tests/Controllers/PaymentControllerTests.cs:48`); filtering it out of the run leaves the mapper uninitialized and fails `ProductControllerTests.EditGet_ProductSharedAcrossMultipleStoresIncludingStaffStore_ShowsFormWithWarning` with a `NullReferenceException` that has nothing to do with Product code (confirmed 2026-08-16: 102/102 pass unfiltered, 93/94 pass with the narrow filter). Same applies anywhere else in this plan that filters `Grand.Web.Store.Tests` by `~Product*` — run that project unfiltered instead.
-
-Expected: all PASS. If anything fails here, stop and fix or report it before starting Task 1 — this plan's safety net depends on a green baseline.
-
-- [ ] **Step 2: Note the test project namespaces/base classes used**
-
-Skim each file's `using` block and test class setup (constructor mocks) — later tasks reuse these mock-setup patterns when writing new `IAdminDataScope` tests. No code change in this step.
-
----
-
-## Task 1: `IAdminDataScope<TEntity>` interface
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs`
-
-**Interfaces:**
-- Produces: `IAdminDataScope<TEntity>` with `Task<bool> HasAccess(TEntity entity)`, `Task<bool> CanView(TEntity entity)` (default interface method, defaults to `HasAccess`), `IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query)`, `string? DefaultStoreId { get; }`, `string ResourceKeyPrefix { get; }` — consumed by Tasks 2-4 (implementations) and Task 7+ (`BaseProductController`)/Task 9+ (shared service).
-
-**Addendum (added after Task 7's review found a real gap — see Task 7's fix round):** `CanView` was added retroactively as a default interface method, so this is additive/source-compatible — `GlobalAdminDataScope` and `VendorProductDataScope` (Tasks 2 and 4) need no change, only `StoreAdminDataScope` (Task 3) gets an override plus a test.
-
-- [ ] **Step 1: Write the interface**
-
-```csharp
-namespace Grand.Web.AdminShared.Interfaces;
-
-/// <summary>
-/// Per-host data-access strategy for an admin-area entity. Implemented once per host
-/// (Admin/Store/Vendor) and injected into shared AdminShared controllers/services so
-/// scope logic lives in one place instead of being duplicated per host.
-/// </summary>
-public interface IAdminDataScope<TEntity>
-{
- /// <summary>Whether the current user may mutate (edit/delete) this specific, already-loaded entity.
- /// This is the strict check — for Store, matches AclMappingExtension.AccessToEntityByStore exactly
- /// (denies global and multi-store entities, only the entity's exclusive single store passes).</summary>
- Task<bool> HasAccess(TEntity entity);
-
- /// <summary>Whether the current user may view/reference this entity (open its edit form, copy it) —
- /// looser than <see cref="HasAccess"/> for hosts where viewing a shared/global entity is allowed but
- /// mutating it isn't. Defaults to <see cref="HasAccess"/> for hosts with no such split (Admin: always
- /// true either way; Vendor: the two are identical, verified against the existing, unsplit
- /// `CheckAccessToProduct`). Only Store overrides this (see Task 3 addendum).</summary>
- Task<bool> CanView(TEntity entity) => HasAccess(entity);
-
- /// <summary>Narrows a query to the entities the current user may see. No-op for global (Admin) scope.</summary>
- IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query);
-
- /// <summary>Store id to default onto new/edited entities. Null when the host has no store concept
- /// (Admin: global, no default; Vendor: not store-scoped at all).</summary>
- string? DefaultStoreId { get; }
-
- /// <summary>Prefix used to build host-specific localization keys, e.g. "Admin", "Vendor". Store
- /// currently has no distinct resource set and uses "Admin" (see Task 6).</summary>
- string ResourceKeyPrefix { get; }
-}
-```
-
-- [ ] **Step 2: Build to confirm it compiles**
-
-Run: `dotnet build src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj`
-Expected: Build succeeded (interface has no consumers yet, so nothing else changes).
-
-- [ ] **Step 3: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs
-git commit -m "Add IAdminDataScope<TEntity> abstraction (ARCH-001 Phase 1)"
-```
-
----
-
-## Task 2: `GlobalAdminDataScope<TEntity>` (Admin host)
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Services/GlobalAdminDataScope.cs`
-- Test: `src/Tests/Grand.Web.Admin.Tests/Services/GlobalAdminDataScopeTests.cs`
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<TEntity>` (Task 1).
-- Produces: `GlobalAdminDataScope<TEntity> : IAdminDataScope<TEntity>` — registered by Admin's `Startup` in Task 5.
-
-- [ ] **Step 1: Write the failing test**
-
-```csharp
-using Grand.Domain.Catalog;
-using Grand.Web.AdminShared.Services;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Grand.Web.Admin.Tests.Services;
-
-[TestClass]
-public class GlobalAdminDataScopeTests
-{
- [TestMethod]
- public async Task HasAccess_AlwaysReturnsTrue()
- {
- var scope = new GlobalAdminDataScope<Product>();
- var result = await scope.HasAccess(new Product());
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void ApplyScope_ReturnsQueryUnchanged()
- {
- var scope = new GlobalAdminDataScope<Product>();
- var query = new[] { new Product { Id = "1" }, new Product { Id = "2" } }.AsQueryable();
-
- var result = scope.ApplyScope(query);
-
- CollectionAssert.AreEqual(query.ToList(), result.ToList());
- }
-
- [TestMethod]
- public void DefaultStoreId_IsNull()
- {
- var scope = new GlobalAdminDataScope<Product>();
- Assert.IsNull(scope.DefaultStoreId);
- }
-
- [TestMethod]
- public void ResourceKeyPrefix_IsAdmin()
- {
- var scope = new GlobalAdminDataScope<Product>();
- Assert.AreEqual("Admin", scope.ResourceKeyPrefix);
- }
-}
-```
-
-- [ ] **Step 2: Run test to verify it fails**
-
-Run: `dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~GlobalAdminDataScopeTests"`
-Expected: FAIL (compile error — `GlobalAdminDataScope` does not exist yet).
-
-- [ ] **Step 3: Write the implementation**
-
-```csharp
-using Grand.Web.AdminShared.Interfaces;
-
-namespace Grand.Web.AdminShared.Services;
-
-public class GlobalAdminDataScope<TEntity> : IAdminDataScope<TEntity>
-{
- public Task<bool> HasAccess(TEntity entity) => Task.FromResult(true);
-
- public IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query) => query;
-
- public string? DefaultStoreId => null;
-
- public string ResourceKeyPrefix => "Admin";
-}
-```
-
-- [ ] **Step 4: Run test to verify it passes**
-
-Run: `dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~GlobalAdminDataScopeTests"`
-Expected: PASS (4/4).
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Services/GlobalAdminDataScope.cs src/Tests/Grand.Web.Admin.Tests/Services/GlobalAdminDataScopeTests.cs
-git commit -m "Add GlobalAdminDataScope for the Admin host (ARCH-001 Phase 1)"
-```
-
----
-
-## Task 3: `StoreAdminDataScope<TEntity>` (Store host)
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Services/StoreAdminDataScope.cs`
-- Test: `src/Tests/Grand.Web.Store.Tests/Services/StoreAdminDataScopeTests.cs`
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<TEntity>` (Task 1), existing `IContextAccessor`/`IWorkContext` (`Grand.Infrastructure`), existing `IStoreLinkEntity` (`Grand.Domain.Stores` — already implemented by `Product`, confirmed at `src/Core/Grand.Domain/Catalog/Product.cs:754`).
-- Produces: `StoreAdminDataScope<TEntity> where TEntity : IStoreLinkEntity` — registered by Store's `Startup` in Task 5.
-
-- [ ] **Step 1: Write the failing tests**
-
-```csharp
-using Grand.Domain.Catalog;
-using Grand.Domain.Customers;
-using Grand.Infrastructure;
-using Grand.Web.AdminShared.Services;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-
-namespace Grand.Web.Store.Tests.Services;
-
-[TestClass]
-public class StoreAdminDataScopeTests
-{
- private Mock<IContextAccessor> _contextAccessor = null!;
- private const string StaffStoreId = "store-1";
-
- [TestInitialize]
- public void Setup()
- {
- var workContext = new Mock<IWorkContext>();
- workContext.Setup(x => x.CurrentCustomer).Returns(new Customer { StaffStoreId = StaffStoreId });
- _contextAccessor = new Mock<IContextAccessor>();
- _contextAccessor.Setup(x => x.WorkContext).Returns(workContext.Object);
- }
-
- // These three mirror AclMappingExtension.AccessToEntityByStore's existing, deliberately strict
- // rule (src/Web/Grand.Web.AdminShared/Extensions/AclMappingExtension.cs), the same rule
- // ProductController.CanAccessProduct already enforces for Edit(POST)/Delete/CopyProduct today
- // (see src/Tests/Grand.Web.Store.Tests/Controllers/ProductControllerTests.cs,
- // Delete_ProductNotLimitedToAnyStore_IsDenied and
- // Delete_ProductInMultipleStoresIncludingStaffStore_IsDenied, both commented
- // "counter-intuitive but current behavior... must not silently fix this"). Access is granted
- // ONLY when the product is limited to stores, is in exactly one store, and that store is the
- // staff member's store — a global product or one shared across multiple stores is denied.
- [TestMethod]
- public async Task HasAccess_ProductNotLimitedToStores_ReturnsFalse()
- {
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = false };
-
- Assert.IsFalse(await scope.HasAccess(product));
- }
-
- [TestMethod]
- public async Task HasAccess_ProductLimitedToOtherStore_ReturnsFalse()
- {
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = true, Stores = ["store-2"] };
-
- Assert.IsFalse(await scope.HasAccess(product));
- }
-
- [TestMethod]
- public async Task HasAccess_ProductLimitedToStaffStoreOnly_ReturnsTrue()
- {
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = true, Stores = [StaffStoreId] };
-
- Assert.IsTrue(await scope.HasAccess(product));
- }
-
- [TestMethod]
- public async Task HasAccess_ProductInMultipleStoresIncludingStaffStore_ReturnsFalse()
- {
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = true, Stores = [StaffStoreId, "store-3"] };
-
- Assert.IsFalse(await scope.HasAccess(product));
- }
-
- [TestMethod]
- public void DefaultStoreId_ReturnsStaffStoreId()
- {
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- Assert.AreEqual(StaffStoreId, scope.DefaultStoreId);
- }
-
- [TestMethod]
- public void ResourceKeyPrefix_IsAdmin()
- {
- // Store has no distinct resource set for Product screens yet (see Task 6) — it renders
- // AdminShared's "Admin.*" keys today, so the migrated scope must keep that behavior.
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- Assert.AreEqual("Admin", scope.ResourceKeyPrefix);
- }
-}
-```
-
-- [ ] **Step 2: Run tests to verify they fail**
-
-Run: `dotnet test src/Tests/Grand.Web.Store.Tests --filter "FullyQualifiedName~StoreAdminDataScopeTests"`
-Expected: FAIL (compile error — type doesn't exist).
-
-- [ ] **Step 3: Write the implementation — delegate to the existing `AccessToEntityByStore` extension**
-
-Do not reimplement the store-access rule. `src/Web/Grand.Web.AdminShared/Extensions/AclMappingExtension.cs` already has it (`AccessToEntityByStore<T>(this T entity, string storeId) where T : BaseEntity, IStoreLinkEntity`), and it's the same rule `ProductController.CanAccessProduct` already enforces today. Add the `BaseEntity` constraint and call it directly:
-
-```csharp
-using Grand.Domain;
-using Grand.Domain.Stores;
-using Grand.Infrastructure;
-using Grand.Web.AdminShared.Extensions;
-using Grand.Web.AdminShared.Interfaces;
-
-namespace Grand.Web.AdminShared.Services;
-
-public class StoreAdminDataScope<TEntity>(IContextAccessor contextAccessor) : IAdminDataScope<TEntity>
- where TEntity : BaseEntity, IStoreLinkEntity
-{
- public Task<bool> HasAccess(TEntity entity)
- {
- var staffStoreId = contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
- return Task.FromResult(entity != null && entity.AccessToEntityByStore(staffStoreId));
- }
-
- public IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query)
- {
- var staffStoreId = contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
- if (string.IsNullOrEmpty(staffStoreId)) return query;
- return query.Where(x => x.LimitedToStores && x.Stores.Contains(staffStoreId) && x.Stores.Count == 1);
- }
-
- public string? DefaultStoreId => contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
-
- public string ResourceKeyPrefix => "Admin";
-}
-```
-
-`ApplyScope` mirrors the same strict rule inline (there's no queryable-friendly overload of `AccessToEntityByStore` — it's written for a single loaded entity) so that a product list built through this scope shows exactly the products `HasAccess` would allow, keeping the two methods consistent with each other.
-
-- [ ] **Step 4: Run tests to verify they pass**
-
-Run: `dotnet test src/Tests/Grand.Web.Store.Tests --filter "FullyQualifiedName~StoreAdminDataScopeTests"`
-Expected: PASS (6/6).
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Services/StoreAdminDataScope.cs src/Tests/Grand.Web.Store.Tests/Services/StoreAdminDataScopeTests.cs
-git commit -m "Add StoreAdminDataScope for the Store host (ARCH-001 Phase 1)"
-```
-
-**Note for Task 7/8:** the current `Grand.Web.Store/Controllers/ProductController.cs:88-92` `CanAccessProduct` helper (added in #786, uses `product.AccessToEntityByStore(staffStoreId)`) and this `HasAccess` implementation must agree. `AccessToEntityByStore` is the existing extension in `Grand.Business.Core.Extensions`; check its exact semantics against the `HasAccess` body above during Task 7 Step 1 and use whichever is authoritative (prefer calling the existing `AccessToEntityByStore` extension from inside `HasAccess` over reimplementing the same rule twice, if its signature fits `IStoreLinkEntity`).
-
-**Addendum — `CanView` override (added after Task 7's review found this task's `HasAccess` alone can't represent Store's actual behavior):**
-
-`Grand.Web.Store/Controllers/ProductController.cs:184-194`'s `Edit(GET)` is NOT `HasAccess` plus a cosmetic warning — it is a materially looser rule that *replaces* the strict check for viewing: a global product or a multi-store product that includes the staff member's store is **allowed to view** (with a warning), and only a product limited to stores that exclude the staff member's store is denied. The existing test `Grand.Web.Store.Tests/Controllers/ProductControllerTests.cs:248-264` (`EditGet_ProductSharedAcrossMultipleStoresIncludingStaffStore_ShowsFormWithWarning`) locks this in with an explicit comment: *"This is the one path that must stay outside any shared 'authorize or redirect' helper."* `Store/ProductController.cs:289-290`'s `CopyProduct` uses the same looser rule (denies only when `LimitedToStores && !Stores.Contains(staff)`).
-
-Add to `StoreAdminDataScope<TEntity>` (Task 3's file), after `HasAccess`:
-
-```csharp
-public Task<bool> CanView(TEntity entity)
-{
- if (entity is null) return Task.FromResult(false);
- var staffStoreId = contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
- var allowed = !entity.LimitedToStores || entity.Stores.Contains(staffStoreId);
- return Task.FromResult(allowed);
-}
-```
-
-Add tests to `StoreAdminDataScopeTests.cs`:
-
-```csharp
-[TestMethod]
-public async Task CanView_ProductNotLimitedToStores_ReturnsTrue()
-{
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- Assert.IsTrue(await scope.CanView(new Product { LimitedToStores = false }));
-}
-
-[TestMethod]
-public async Task CanView_ProductInMultipleStoresIncludingStaffStore_ReturnsTrue()
-{
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = true, Stores = [StaffStoreId, "store-3"] };
- Assert.IsTrue(await scope.CanView(product));
-}
-
-[TestMethod]
-public async Task CanView_ProductLimitedToOtherStore_ReturnsFalse()
-{
- var scope = new StoreAdminDataScope<Product>(_contextAccessor.Object);
- var product = new Product { LimitedToStores = true, Stores = ["store-2"] };
- Assert.IsFalse(await scope.CanView(product));
-}
-```
-
-Run `dotnet test src/Tests/Grand.Web.Store.Tests --filter "FullyQualifiedName~StoreAdminDataScopeTests"` — expect 9/9 passing. Commit alongside (or amend into) Task 3's existing commit is fine since this is a direct addendum to the same file/task, not a new task.
-
----
-
-## Task 4: `VendorProductDataScope` (Vendor host, Product-specific)
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Services/VendorProductDataScope.cs`
-- Test: `src/Tests/Grand.Web.Vendor.Tests/Services/VendorProductDataScopeTests.cs`
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<Product>` (Task 1), existing `IContextAccessor`/`IWorkContext.CurrentVendor`.
-- Produces: `VendorProductDataScope : IAdminDataScope<Product>` — registered by Vendor's `Startup` in Task 5.
-
-Named `VendorProductDataScope` (not generic `VendorAdminDataScope<TEntity>`): vendor ownership is keyed by `VendorId` on `Product`, but other entities (`Order`, `Shipment`, ...) use different owner fields (see `src/Web/Grand.Web.Vendor/Extensions/HasAccess.cs`), so a generic vendor scope would need a marker interface that doesn't exist yet. Out of scope for this plan — future entities get their own `Vendor<Entity>DataScope` when migrated, following this same shape.
-
-- [ ] **Step 1: Write the failing tests**
-
-```csharp
-using Grand.Domain.Catalog;
-using Grand.Domain.Customers;
-using Grand.Domain.Vendors;
-using Grand.Infrastructure;
-using Grand.Web.AdminShared.Services;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Moq;
-
-namespace Grand.Web.Vendor.Tests.Services;
-
-[TestClass]
-public class VendorProductDataScopeTests
-{
- private Mock<IContextAccessor> _contextAccessor = null!;
- private const string VendorId = "vendor-1";
-
- [TestInitialize]
- public void Setup()
- {
- var workContext = new Mock<IWorkContext>();
- workContext.Setup(x => x.CurrentVendor).Returns(new Domain.Vendors.Vendor { Id = VendorId });
- _contextAccessor = new Mock<IContextAccessor>();
- _contextAccessor.Setup(x => x.WorkContext).Returns(workContext.Object);
- }
-
- [TestMethod]
- public async Task HasAccess_OwnProduct_ReturnsTrue()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- Assert.IsTrue(await scope.HasAccess(new Product { VendorId = VendorId }));
- }
-
- [TestMethod]
- public async Task HasAccess_OtherVendorsProduct_ReturnsFalse()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- Assert.IsFalse(await scope.HasAccess(new Product { VendorId = "vendor-2" }));
- }
-
- [TestMethod]
- public async Task HasAccess_NullProduct_ReturnsFalse()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- Assert.IsFalse(await scope.HasAccess(null!));
- }
-
- [TestMethod]
- public void ApplyScope_FiltersToOwnVendorId()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- var query = new[]
- {
- new Product { Id = "1", VendorId = VendorId },
- new Product { Id = "2", VendorId = "vendor-2" }
- }.AsQueryable();
-
- var result = scope.ApplyScope(query).ToList();
-
- Assert.AreEqual(1, result.Count);
- Assert.AreEqual("1", result[0].Id);
- }
-
- [TestMethod]
- public void DefaultStoreId_IsNull()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- Assert.IsNull(scope.DefaultStoreId);
- }
-
- [TestMethod]
- public void ResourceKeyPrefix_IsVendor()
- {
- var scope = new VendorProductDataScope(_contextAccessor.Object);
- Assert.AreEqual("Vendor", scope.ResourceKeyPrefix);
- }
-}
-```
-
-- [ ] **Step 2: Run tests to verify they fail**
-
-Run: `dotnet test src/Tests/Grand.Web.Vendor.Tests --filter "FullyQualifiedName~VendorProductDataScopeTests"`
-Expected: FAIL (compile error).
-
-- [ ] **Step 3: Write the implementation**
-
-```csharp
-using Grand.Domain.Catalog;
-using Grand.Infrastructure;
-using Grand.Web.AdminShared.Interfaces;
-
-namespace Grand.Web.AdminShared.Services;
-
-public class VendorProductDataScope(IContextAccessor contextAccessor) : IAdminDataScope<Product>
-{
- public Task<bool> HasAccess(Product entity)
- {
- if (entity is null) return Task.FromResult(false);
- return Task.FromResult(entity.VendorId == contextAccessor.WorkContext.CurrentVendor.Id);
- }
-
- public IQueryable<Product> ApplyScope(IQueryable<Product> query)
- {
- var vendorId = contextAccessor.WorkContext.CurrentVendor.Id;
- return query.Where(x => x.VendorId == vendorId);
- }
-
- public string? DefaultStoreId => null;
-
- public string ResourceKeyPrefix => "Vendor";
-}
-```
-
-- [ ] **Step 4: Run tests to verify they pass**
-
-Run: `dotnet test src/Tests/Grand.Web.Vendor.Tests --filter "FullyQualifiedName~VendorProductDataScopeTests"`
-Expected: PASS (6/6).
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Services/VendorProductDataScope.cs src/Tests/Grand.Web.Vendor.Tests/Services/VendorProductDataScopeTests.cs
-git commit -m "Add VendorProductDataScope for the Vendor host (ARCH-001 Phase 1)"
-```
-
-**Note:** `Grand.Web.Vendor/Extensions/HasAccess.cs:19` (`HasAccessToProduct`) stays as-is — it's still used by other Vendor controllers (Order, Shipment, etc. also call sibling `HasAccessTo*` methods from the same file) that are out of scope for this plan. Do not delete or modify that file in this plan.
-
----
-
-## Task 5: DI registration in all three hosts
-
-**Files:**
-- Modify: `src/Web/Grand.Web.Admin/Startup/*.cs` (find via Step 1 below)
-- Modify: `src/Web/Grand.Web.Store/Startup/*.cs`
-- Modify: `src/Web/Grand.Web.Vendor/Startup/*.cs`
-
-**Interfaces:**
-- Consumes: `GlobalAdminDataScope<TEntity>`, `StoreAdminDataScope<TEntity>`, `VendorProductDataScope` (Tasks 2-4).
-- Produces: `IAdminDataScope<Product>` resolvable via DI in each host — consumed by `BaseProductController` (Task 7) and the shared `ProductViewModelService` (Task 9).
-
-- [ ] **Step 1: Find where each host registers its own services today**
-
-Run: `grep -rln "AddScoped<IProductViewModelService" src/Web/Grand.Web.Admin src/Web/Grand.Web.Store src/Web/Grand.Web.Vendor`
-
-This locates the `IStartupApplication` (or equivalent DI extension) file per host where the Product-related registration already lives — register the new scope next to it.
-
-- [ ] **Step 2: Register in Admin**
-
-In the file found for `Grand.Web.Admin`, add:
-```csharp
-services.AddScoped<IAdminDataScope<Product>, GlobalAdminDataScope<Product>>();
-```
-(Add `using Grand.Web.AdminShared.Interfaces;`, `using Grand.Web.AdminShared.Services;`, `using Grand.Domain.Catalog;` if not already present.)
-
-- [ ] **Step 3: Register in Store**
-
-In the file found for `Grand.Web.Store`, add:
-```csharp
-services.AddScoped<IAdminDataScope<Product>, StoreAdminDataScope<Product>>();
-```
-
-- [ ] **Step 4: Register in Vendor**
-
-In the file found for `Grand.Web.Vendor`, add:
-```csharp
-services.AddScoped<IAdminDataScope<Product>, VendorProductDataScope>();
-```
-
-- [ ] **Step 5: Build all three hosts**
-
-Run:
-```
-dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
-dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj
-dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj
-```
-Expected: all succeed (registration has no consumers yet, so this only proves the DI call compiles).
-
-- [ ] **Step 6: Commit**
-
-```bash
-git add -A
-git commit -m "Register IAdminDataScope<Product> in Admin, Store, Vendor hosts (ARCH-001 Phase 1)"
-```
-
----
-
-## Task 6: Resource-key-prefix audit for the Product vertical
-
-**Files:**
-- No source changes — this task produces a decision table consumed by Tasks 7-10.
-
-**Interfaces:** none.
-
-**Why:** confirmed by direct comparison of `PrepareProductListModel` in AdminShared vs Vendor — Vendor's copy uses `"Vendor.Common.All"` / `"Vendor.Catalog.Products.List.SearchPublished.*"` where AdminShared's uses `"Admin.*"`. `ResourceKeyPrefix` (Task 1) exists to make this swap mechanical, but **do not assume every `Admin.X` key has a matching `Vendor.X` key** — some resources may only exist under one prefix, in which case the key must stay a literal, not be templated.
-
-- [ ] **Step 1: Extract every resource key literal referenced by the three controllers and both services**
-
-Run (from repo root):
-```
-grep -ohE 'GetResource\("[A-Za-z]+\.[^"]+"\)' \
- src/Web/Grand.Web.Admin/Controllers/ProductController.cs \
- src/Web/Grand.Web.Store/Controllers/ProductController.cs \
- src/Web/Grand.Web.Vendor/Controllers/ProductController.cs \
- src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs \
- src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs \
- | sed -E 's/GetResource\("([A-Za-z]+)\.([^"]+)"\)/\1|\2/' \
- | sort -u > /tmp/product-resource-keys.txt
-```
-
-- [ ] **Step 2: Group by suffix (the part after the first `.`) and diff prefixes**
-
-For each unique suffix, note which prefixes (`Admin`, `Store`, `Vendor`) appear. Three outcomes:
-1. Only `Admin` appears (e.g. today's Store host, which has no separate resource set) → keep the literal `"Admin.<suffix>"` in the shared code; do not template it.
-2. Both `Admin` and `Vendor` appear for the same suffix (confirmed case: `Common.All`, `Catalog.Products.List.SearchPublished.*`, `Catalog.Products.Added`, `Catalog.Products.Updated`, `Catalog.Products.Deleted`, `Catalog.Products.Fields.ChangedWarning`, `Catalog.Products.Permissions`) → template as `$"{scope.ResourceKeyPrefix}.<suffix>"`.
-3. A prefix+suffix combination appears in only one host with no equivalent elsewhere and looks like a real per-host resource (not just a stray) → keep it as a literal guarded by `scope.ResourceKeyPrefix == "Vendor"` (or an `if`/virtual override) rather than templating — templating here would silently look up a resource key that doesn't exist for other hosts, which renders as the raw key text.
-
-- [ ] **Step 3: Save the table as a code comment**
-
-Add the resulting suffix → outcome table as a comment block at the top of `BaseProductController` (created in Task 7) so it stays next to the code it governs, e.g.:
-```csharp
-// Resource-key-prefix audit (2026-08-16, ARCH-001 Phase 1 Task 6):
-// Templated via {scope.ResourceKeyPrefix}: Common.All, Catalog.Products.List.SearchPublished.*,
-// Catalog.Products.{Added,Updated,Deleted}, Catalog.Products.Fields.ChangedWarning,
-// Catalog.Products.Permissions.
-// Admin-only literal (Store has no separate resource set): <fill in from Step 2>.
-// Host-specific, not templated: <fill in from Step 2>.
-```
-
-No commit for this task alone — its output lands inside Task 7's commit.
-
----
-
-## Task 7: `BaseProductController` skeleton + worked region ("Product list / create / edit / delete")
-
-This is the template every remaining region in Task 8 follows. Do this one region fully and correctly before touching any other region.
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs`
-- Test: `src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs` (new file — see Task 13 for what happens to the three existing per-host `ProductControllerTests.cs` files)
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<Product>` (Task 1, registered per-host in Task 5), existing `IProductViewModelService`, `IProductService`, and the other 8 services already injected by all three current controllers (see the three constructors — they are identical in shape).
-- Produces: `BaseProductController` — subclassed by all three hosts in Task 11.
-
-- [ ] **Step 1: Reconcile the three current `List`/`Create`/`Edit`/`Delete`/`CopyProduct` bodies**
-
-Read (already done for this plan — reproduced here for reference, do not re-read unless verifying):
-- `src/Web/Grand.Web.Admin/Controllers/ProductController.cs:78-291`
-- `src/Web/Grand.Web.Store/Controllers/ProductController.cs:94-...` (equivalent region, includes the `CanAccessProduct` helper at line 88)
-- `src/Web/Grand.Web.Vendor/Controllers/ProductController.cs:91-307` (includes the `CheckAccessToProduct` helper at line 81)
-
-Differences found, and how each is resolved:
-| Difference | Admin | Store | Vendor | Resolution |
-|---|---|---|---|---|
-| Access check on `Edit`/`Delete`/`CopyProduct` | none | `CanAccessProduct` (`AccessToEntityByStore`) | `CheckAccessToProduct` (`HasAccessToProduct`) | `await scope.HasAccess(product)` |
-| `GoToSku` access check | none | checks `CanAccessProduct` (note: current Store code has a **pre-existing bug** — it redirects to `Edit` regardless of whether `CanAccessProduct` returns true or false; preserve as a separate follow-up, do not silently fix inside this refactor — see Step 1a) | none | `if (product != null) { if (!await scope.HasAccess(product)) { /* preserve existing per-host behavior, see 1a */ } return RedirectToAction("Edit", new { id = product.Id }); }` |
-| `List()` storeId arg | `PrepareProductListModel()` | `PrepareProductListModel(StaffStoreId)` | `PrepareProductListModel()` | `PrepareProductListModel(scope.DefaultStoreId ?? "")` once Task 9 lands; until then keep the current 4 arities separate per interface signature |
-| `Create()` GET default `model.StoreId` | not set | `= StaffStoreId` | not set | `model.StoreId = scope.DefaultStoreId;` (no-op when null) |
-| `Create()`/`Edit()` POST `model.Stores`/`model.StoreId` stamping | not set | `[StaffStoreId]` / `StaffStoreId` | not set | `if (scope.DefaultStoreId is not null) { model.Stores = [scope.DefaultStoreId]; model.StoreId = scope.DefaultStoreId; }` |
-| `Edit()` GET extra "still has other stores" warning branch (Store only, lines 184-194) | absent | present | absent | Keep as a `protected virtual` no-op hook `EditWarningCheck(Product product)` overridden only in the Store subclass (Task 11) — this is host UI copy behavior, not scope logic, so it does not belong in `IAdminDataScope`. |
-| `PrepareProductModel(model, product, bool, bool)` arity | 4-arg | 4-arg | **3-arg** (no `excludeProperties`) | Resolved by Task 9 (interface unification) — until Task 9 lands, `BaseProductController` calls the 4-arg AdminShared signature with `excludeProperties: false` as Vendor's implicit default; verify against Vendor's actual usage (`false` in `Create()`, `true` in the redisplay-on-invalid branches) before assuming — re-check `src/Web/Grand.Web.Vendor/Controllers/ProductController.cs:139,157,174,222` line by line. |
-| Resource key prefix | `"Admin.*"` | `"Admin.*"` | `"Vendor.*"` | `$"{scope.ResourceKeyPrefix}.Catalog.Products.Added"` etc., per Task 6's table |
-| `DeleteSelected` | present, no controller-level filter | absent | present, no controller-level filter (Vendor's *service* — `Grand.Web.Vendor/Services/ProductViewModelService.cs:687` — filters per-id by `HasAccessToProduct`, but the controller doesn't) | **Not harmless** — MVC routes actions regardless of whether a host's views link to them, so shipping this unfiltered into the shared base hands Store a brand-new unscoped bulk-delete endpoint once Task 11 subclasses it, and leaves Vendor's only protection sitting in one host's service rather than the controller like every other guarded action here. Filter ids through `scope.HasAccess` in the base controller before delegating — see the code below. |
-
-- [ ] **Step 1a: File a note, don't fix, the Store `GoToSku` bug found above**
-
-Add a `// TODO(ARCH-001-followup):` comment at the merged `GoToSku` call site describing the found inconsistency (Store's current code redirects to Edit on both branches of the access check) and leave the **new, merged** behavior doing the historically-safer thing: redirect to `List` (not `Edit`) when `HasAccess` is false, matching Vendor's stricter pattern, since silently landing on the edit screen of a product you don't have access to is the more dangerous default. Call this out explicitly in the PR description this task's commit goes into — this is a deliberate behavior tightening, not an accidental one.
-
-- [ ] **Step 2: Write `BaseProductController` with this region only**
-
-```csharp
-using Grand.Business.Core.Dto;
-using Grand.Business.Core.Extensions;
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Interfaces.Common.Directory;
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Interfaces.ExportImport;
-using Grand.Business.Core.Interfaces.Storage;
-using Grand.Domain.Catalog;
-using Grand.Domain.Common;
-using Grand.Domain.Media;
-using Grand.Domain.Permissions;
-using Grand.SharedKernel.Extensions;
-using Grand.Web.AdminShared.Extensions.Mapping;
-using Grand.Web.AdminShared.Interfaces;
-using Grand.Web.AdminShared.Models.Catalog;
-using Grand.Web.AdminShared.Models.Orders;
-using Grand.Web.Common.Controllers;
-using Grand.Web.Common.DataSource;
-using Grand.Web.Common.Extensions;
-using Grand.Web.Common.Filters;
-using Grand.Web.Common.Helpers;
-using Grand.Web.Common.Localization;
-using Grand.Web.Common.Security.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Rendering;
-using Microsoft.AspNetCore.StaticFiles;
-
-namespace Grand.Web.AdminShared.Controllers;
-
-// Resource-key-prefix audit (2026-08-16, ARCH-001 Phase 1 Task 6, corrected after review — see Task 6's
-// ledger entry). Inlined in full here (not just referenced) since planning artifacts under .superpowers/
-// are untracked and do not survive in the repo once this branch merges.
-//
-// Templated via {scope.ResourceKeyPrefix} (Admin.<suffix> and Vendor.<suffix> both exist) — 22:
-// Common.All, Customers.Guest, Configuration.Tax.Settings.TaxCategories.None,
-// Catalog.Products.Added, Catalog.Products.Updated, Catalog.Products.Deleted,
-// Catalog.Products.Fields.ChangedWarning, Catalog.Products.Fields.DeliveryDate.None,
-// Catalog.Products.Fields.Warehouse.None, Catalog.Products.Bids.CantDeleteWithOrder,
-// Catalog.Products.List.SkuNotFound, Catalog.Products.List.SearchPublished.All,
-// Catalog.Products.List.SearchPublished.PublishedOnly, Catalog.Products.List.SearchPublished.UnpublishedOnly,
-// Catalog.Products.List.SearchPublished.MarkAsNew, Catalog.ProductReservations.CantDeleteWithOrder,
-// Catalog.Products.Calendar.CannotChangeInterval,
-// Catalog.Products.ProductAttributes.Attributes.ValidationRules.MinLength,
-// Catalog.Products.ProductAttributes.Attributes.ValidationRules.MaxLength,
-// Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileAllowedExtensions,
-// Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileMaximumSize,
-// Catalog.Products.ProductAttributes.Attributes.ValidationRules.DefaultValue.
-//
-// Admin-only literal (no Vendor equivalent call site; keep as literal "Admin.<suffix>") — 6:
-// Catalog.Products.Permissions (Vendor has no Permissions-suffixed resource lookup anywhere - its
-// permission-denied paths don't emit this message), Catalog.Products.List.SearchPublished.ShowOnHomePage,
-// Catalog.Products.Imported, Catalog.Products.TierPrices.Fields.CustomerGroup.All,
-// Catalog.Products.TierPrices.Fields.Store.All, Common.UploadFile.
-//
-// Host-specific, not templated — 0: none found; every "Vendor.<suffix>" call site has a matching
-// "Admin.<suffix>" one, so nothing needs a scope.ResourceKeyPrefix == "Vendor" guard instead of templating.
-//
-// Store makes no separate resource lookups at all - every Store call site uses the literal "Admin.*" key
-// directly (Store has no distinct resource set), consistent with StoreAdminDataScope.ResourceKeyPrefix
-// returning "Admin".
-
-[PermissionAuthorize(PermissionSystemName.Products)]
-public abstract class BaseProductController(
- IProductViewModelService productViewModelService,
- IProductService productService,
- IInventoryManageService inventoryManageService,
- ILanguageService languageService,
- ITranslationService translationService,
- IProductReservationService productReservationService,
- IAuctionService auctionService,
- IDateTimeService dateTimeService,
- IPermissionService permissionService,
- IEnumTranslationService enumTranslationService,
- IAdminDataScope<Product> scope)
- : BaseController
-{
- /// <summary>Hook for host-specific UI-copy warnings that aren't access-scope decisions.
- /// Overridden by the Store subclass; no-op everywhere else.</summary>
- protected virtual void EditWarningCheck(Product product) { }
-
- #region Product list / create / edit / delete
-
- public IActionResult Index() => RedirectToAction("List");
-
- public async Task<IActionResult> List()
- {
- var model = await productViewModelService.PrepareProductListModel(scope.DefaultStoreId ?? "");
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.List)]
- [HttpPost]
- public async Task<IActionResult> ProductList(DataSourceRequest command, ProductListModel model)
- {
- if (scope.DefaultStoreId is not null) model.SearchStoreId = scope.DefaultStoreId;
-
- var (productModels, totalCount) =
- await productViewModelService.PrepareProductsModel(model, command.Page, command.PageSize);
- return Json(new DataSourceResult { Data = productModels.ToList(), Total = totalCount });
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- [HttpPost]
- public async Task<IActionResult> GoToSku(ProductListModel model)
- {
- var product = await productService.GetProductBySku(model.GoDirectlyToSku);
- if (product != null)
- {
- if (!await scope.HasAccess(product))
- return RedirectToAction("List", "Product"); // TODO(ARCH-001-followup): see Task 7 Step 1a
- return RedirectToAction("Edit", "Product", new { id = product.Id });
- }
-
- Warning(translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SkuNotFound"));
- return RedirectToAction("List", "Product");
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- public async Task<IActionResult> Create()
- {
- var model = new ProductModel { StoreId = scope.DefaultStoreId };
- await productViewModelService.PrepareProductModel(model, null, true, true);
- await AddLocales(languageService, model.Locales);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Create(ProductModel model, bool continueEditing)
- {
- if (ModelState.IsValid)
- {
- if (scope.DefaultStoreId is not null)
- {
- model.Stores = [scope.DefaultStoreId];
- model.StoreId = scope.DefaultStoreId;
- }
-
- var product = await productViewModelService.InsertProductModel(model);
- Success(translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.Added"));
- return continueEditing ? RedirectToAction("Edit", new { id = product.Id }) : RedirectToAction("List");
- }
-
- if (scope.DefaultStoreId is not null) model.StoreId = scope.DefaultStoreId;
- await productViewModelService.PrepareProductModel(model, null, false, true);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Preview)]
- public async Task<IActionResult> Edit(string id)
- {
- var product = await productService.GetProductById(id, true);
- if (product == null) return RedirectToAction("List");
-
- EditWarningCheck(product);
- // CanView, not HasAccess: viewing a shared/global product is allowed on Store (with a warning
- // from EditWarningCheck above); only mutating one is restricted to the exclusive single-store
- // owner. See IAdminDataScope<TEntity>.CanView's doc comment and Task 3's addendum.
- if (!await scope.CanView(product)) return RedirectToAction("List");
-
- var model = product.ToModel(dateTimeService);
- if (scope.DefaultStoreId is not null) model.StoreId = scope.DefaultStoreId;
- await productViewModelService.PrepareProductModel(model, product, false, false);
- await AddLocales(languageService, model.Locales, (locale, languageId) =>
- {
- locale.Name = product.GetTranslation(x => x.Name, languageId, false);
- locale.ShortDescription = product.GetTranslation(x => x.ShortDescription, languageId, false);
- locale.FullDescription = product.GetTranslation(x => x.FullDescription, languageId, false);
- locale.MetaKeywords = product.GetTranslation(x => x.MetaKeywords, languageId, false);
- locale.MetaDescription = product.GetTranslation(x => x.MetaDescription, languageId, false);
- locale.MetaTitle = product.GetTranslation(x => x.MetaTitle, languageId, false);
- locale.SeName = product.GetSeName(languageId, false);
- });
-
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Edit)]
- [HttpPost]
- [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
- public async Task<IActionResult> Edit(ProductModel model, bool continueEditing)
- {
- var product = await productService.GetProductById(model.Id, true);
- if (product == null) return RedirectToAction("List");
- if (!await scope.HasAccess(product)) return RedirectToAction("Edit", new { id = product.Id });
-
- if (model.Ticks != product.Ticks)
- {
- Error(translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.Fields.ChangedWarning"));
- return RedirectToAction("Edit", new { id = product.Id });
- }
-
- if (ModelState.IsValid)
- {
- if (scope.DefaultStoreId is not null)
- {
- model.Stores = [scope.DefaultStoreId];
- model.StoreId = scope.DefaultStoreId;
- }
-
- product = await productViewModelService.UpdateProductModel(product, model);
- Success(translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.Updated"));
- if (continueEditing)
- {
- await SaveSelectedTabIndex();
- return RedirectToAction("Edit", new { id = product.Id });
- }
-
- return RedirectToAction("List");
- }
-
- if (scope.DefaultStoreId is not null) model.StoreId = scope.DefaultStoreId;
- await productViewModelService.PrepareProductModel(model, product, false, true);
- return View(model);
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> Delete(string id)
- {
- var product = await productService.GetProductById(id, true);
- if (product == null) return RedirectToAction("List");
- if (!await scope.HasAccess(product)) return RedirectToAction("Edit", new { id });
-
- if (ModelState.IsValid)
- {
- await productViewModelService.DeleteProduct(product);
- Success(translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.Deleted"));
- return RedirectToAction("List");
- }
-
- Error(ModelState);
- return RedirectToAction("Edit", new { id });
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Delete)]
- [HttpPost]
- public async Task<IActionResult> DeleteSelected(ICollection<string> selectedIds)
- {
- if (selectedIds == null || selectedIds.Count == 0) return Json(new { Result = true });
-
- // This is a mutation (bulk delete), so it uses the strict HasAccess, matching Edit(POST)/Delete
- // above — not a no-op pass-through to the service. Without this filter, Store gains an
- // unscoped bulk-delete endpoint (any store staff could delete any product id in the system,
- // bypassing AccessToEntityByStore entirely) purely because MVC routes actions regardless of
- // whether a host's views ever link to them. See Task 7's review for the full analysis.
- var products = await productService.GetProductsByIds(selectedIds.ToArray(), true);
- var allowedIds = new List<string>();
- foreach (var product in products)
- if (await scope.HasAccess(product))
- allowedIds.Add(product.Id);
-
- if (allowedIds.Count > 0) await productViewModelService.DeleteSelected(allowedIds);
- return Json(new { Result = true });
- }
-
- [PermissionAuthorizeAction(PermissionActionName.Create)]
- [HttpPost]
- public async Task<IActionResult> CopyProduct(ProductModel model,
- [FromServices] ICopyProductService copyProductService, [FromServices] IPictureService pictureService)
- {
- var copyModel = model.CopyProductModel;
- try
- {
- var originalProduct = await productService.GetProductById(copyModel.Id, true);
- // CanView, not HasAccess: Store's original CopyProduct denies only when LimitedToStores is
- // true AND the staff member's store isn't among them — the same looser rule as Edit(GET)
- // above, not the strict mutation rule. See IAdminDataScope<TEntity>.CanView.
- if (!await scope.CanView(originalProduct)) return RedirectToAction("List");
-
- if (scope.DefaultStoreId is not null)
- {
- originalProduct.LimitedToStores = true;
- originalProduct.Stores.Clear();
- originalProduct.Stores.Add(scope.DefaultStoreId);
- }
-
- var newProduct = await copyProductService.CopyProduct(originalProduct, copyModel.Name, copyModel.Published);
- if (copyModel.CopyImages) await CopyImages(originalProduct, newProduct, pictureService);
-
- Success("The product has been copied successfully");
- return RedirectToAction("Edit", new { id = newProduct.Id });
- }
- catch (Exception exc)
- {
- Error(exc.Message);
- return RedirectToAction("Edit", new { id = copyModel.Id });
- }
- }
-
- private async Task CopyImages(Product originalProduct, Product newProduct, IPictureService pictureService)
- {
- foreach (var productPicture in originalProduct.ProductPictures)
- {
- var picture = await pictureService.GetPictureById(productPicture.PictureId);
- var pictureCopy = await pictureService.InsertPicture(
- await pictureService.LoadPictureBinary(picture),
- picture.MimeType,
- pictureService.GetPictureSeName(newProduct.Name),
- picture.AltAttribute,
- picture.TitleAttribute,
- false,
- Reference.Product,
- newProduct.Id);
-
- await productService.InsertProductPicture(new ProductPicture {
- PictureId = pictureCopy.Id,
- DisplayOrder = productPicture.DisplayOrder,
- IsDefault = productPicture.IsDefault
- }, newProduct.Id);
- }
- }
-
- #endregion
-}
-```
-
-Note: `originalProduct.VendorId` is untouched by `CopyProduct` above — verify against Vendor's actual current behavior (does a vendor-copied product get `VendorId` stamped anywhere, e.g. inside `copyProductService.CopyProduct`?) during Step 1; if Vendor's controller relies on `CopyProduct` internally reading `IWorkContext.CurrentVendor`, no controller-level change is needed and this note can be deleted.
-
-- [ ] **Step 3: Write `BaseProductControllerTests` covering the merged access-check behavior**
-
-Port the `Edit`/`Delete`/`CopyProduct`/`GoToSku` access-denied and access-granted test cases already present across the three existing `ProductControllerTests.cs` files (Task 0) into this one file, parameterized over a mocked `IAdminDataScope<Product>` instead of three different concrete access mechanisms. Use `Moq` to set up `scope.HasAccess(...)` returning `true`/`false` per case — this replaces, rather than duplicates, the equivalent cases in the per-host files (removed in Task 13).
-
-- [ ] **Step 4: Run the new tests**
-
-Run: `dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~BaseProductControllerTests"`
-Expected: PASS. `BaseProductController` is abstract and has no host yet, so these tests instantiate it via a minimal test-only subclass (e.g. `private class TestProductController(...) : BaseProductController(...)`) if MSTest/Moq cannot mock an abstract class directly for the actions under test.
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs
-git commit -m "Add BaseProductController with the list/create/edit/delete region (ARCH-001 Phase 1)"
-```
-
-Do **not** proceed to Task 11 (host subclasses) yet — `BaseProductController` is incomplete until Task 8 migrates the remaining 23 regions.
-
----
-
-## Task 8: Migrate the remaining 23 `#region`s into `BaseProductController`
-
-One region per checklist row, each following Task 7's template exactly: read the region in all three current controllers, build the difference table, resolve every difference through `scope`/`ResourceKeyPrefix`/a `protected virtual` hook, append the merged region to `BaseProductController`, port the corresponding test cases, run tests, commit. Each row is independently testable and commit-able — do not batch multiple rows into one commit.
-
-**Files (per row):**
-- Modify: `src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs` (append the region)
-- Modify: `src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs` (append test cases for the region)
-- Read: the matching region in all three of `src/Web/Grand.Web.{Admin,Store,Vendor}/Controllers/ProductController.cs`, located by the line numbers below (current as of this plan's authoring — re-locate by region name if line numbers have drifted).
-
-| # | Region | Admin start line | Store start line* | Vendor start line* |
-|---|---|---|---|---|
-| 1 | Required products | 293 | (grep `#region Required products`) | (grep) |
-| 2 | Product categories | 347 | " | " |
-| 3 | Product collections | 415 | " | " |
-| 4 | Related products | 483 | " | " |
-| 5 | Similar products | 576 | " | " |
-| 6 | Bundle products | 669 | " | " |
-| 7 | Cross-sell products | 762 | " | " |
-| 8 | Recommended products | 845 | " | " |
-| 9 | Associated products | 927 | " | " |
-| 10 | Product pictures | 1029 | " | " |
-| 11 | Product specification attributes | 1161 | " | " |
-| 12 | Purchased with order | 1278 | " | " |
-| 13 | Reviews | 1308 | " | " |
-| 14 | Export / Import | 1338 | " | " |
-| 15 | Bulk editing | 1406 | " | " |
-| 16 | Product currency price | 1446 | " | " |
-| 17 | Tier prices | 1559 | " | " |
-| 18 | Product attributes | 1673 | " | " |
-| 19 | Product attributes. Condition | 1791 | " | " |
-| 20 | Product attribute values | 1828 | " | " |
-| 21 | Product attribute combinations | 2031 | " | " |
-| 22 | Product Attribute combination - tier prices | 2139 | " | " |
-| 23 | Reservation | 2219 | " | " |
-| 24 | Bids | 2433 | " | " |
-
-*Store and Vendor line numbers were not pre-extracted for every region (only the shared region list, confirmed identical region names/order across all three files via `grep -n "#region" <file>` on 2026-08-16). Locate each region in Store/Vendor with `grep -n "#region <name>" src/Web/Grand.Web.{Store,Vendor}/Controllers/ProductController.cs` at the start of that row's work — do not assume the same line number as Admin.
-
-- [ ] **Step 1 (repeat per row): Read the region in all three controllers and build the difference table**
-
-Same procedure as Task 7 Step 1. Pay special attention to:
-- Any `_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId` or `.CurrentVendor` reference → route through `scope`.
-- Any `HasAccessToProduct`/`CanAccessProduct`/`CheckAccessToProduct` call → `await scope.HasAccess(...)`.
-- Any `"Admin.*"` / `"Vendor.*"` resource key → check against Task 6's table before templating.
-- Any region present in only one or two of the three controllers (not all 24 regions are guaranteed to exist verbatim in all three — confirm with `grep -c "#region" <file>` per host before assuming symmetry; a region missing from one host means that host's subclass simply never routes to those actions, which is fine — the shared method still exists, just unused by that host's views).
-
-- [ ] **Step 2 (repeat per row): Append the merged region and its tests, run tests, commit**
-
-```bash
-dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~BaseProductControllerTests"
-git add src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs
-git commit -m "Migrate '<region name>' region into BaseProductController (ARCH-001 Phase 1)"
-```
-
-- [ ] **Step 3: After all 24 rows are committed, confirm `BaseProductController`'s member list is a superset of all three original controllers' public actions**
-
-Run:
-```
-grep -oE "public (async )?(Task|IActionResult|JsonResult)[^(]*\(" src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs | sort -u > /tmp/base.txt
-grep -oE "public (async )?(Task|IActionResult|JsonResult)[^(]*\(" src/Web/Grand.Web.Admin/Controllers/ProductController.cs | sort -u > /tmp/admin.txt
-grep -oE "public (async )?(Task|IActionResult|JsonResult)[^(]*\(" src/Web/Grand.Web.Store/Controllers/ProductController.cs | sort -u > /tmp/store.txt
-grep -oE "public (async )?(Task|IActionResult|JsonResult)[^(]*\(" src/Web/Grand.Web.Vendor/Controllers/ProductController.cs | sort -u > /tmp/vendor.txt
-diff /tmp/base.txt /tmp/admin.txt
-diff /tmp/base.txt /tmp/store.txt
-diff /tmp/base.txt /tmp/vendor.txt
-```
-Expected: no unexplained diffs (action name + parameter type list should match; return-type wrapper differences like `Task<IActionResult>` vs `IActionResult` are fine to differ if intentional). Any method present in an old controller but missing from `BaseProductController` is a gap — go back and migrate it before moving to Task 9.
-
----
-
-## Task 9: Unify `IProductViewModelService` — drop `storeId` params, inject `IAdminDataScope<Product>`, worked method (`PrepareProductListModel`)
-
-**Files:**
-- Modify: `src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs`
-- Modify: `src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs`
-- Modify: `src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs` — every call site of the 13 methods listed in Step 1 that Task 8 already migrated into a region (Required products, Related/Similar/Bundle/Cross-sell/Recommended/Associated products, Bulk editing, Tier prices, the attribute-value-association popup) loses its `storeId`/`scope.DefaultStoreId` argument in this same task. Find them with `grep -n "scope.DefaultStoreId" src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs` before starting Step 2 below, and fix every hit that calls one of the 13 methods.
-- Test: `src/Tests/Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs` (existing file, extend)
-- Test: `src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs` — update any test asserting the old arity for the 13 methods
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<Product>` (Task 1).
-- Produces: `IProductViewModelService.PrepareProductListModel()` (no `storeId` parameter — scope comes from the injected `IAdminDataScope<Product>` instead) — consumers updated in Task 8's regions and `BaseProductController.List()` (Task 7, revisit).
-
-**Design decision (confirmed by comparing the two current interfaces at `src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs` vs `src/Web/Grand.Web.Vendor/Interfaces/IProductViewModelService.cs`):** AdminShared's interface threads scope through explicit `storeId` parameters on ~10 methods; Vendor's interface has no such parameters and instead reads `IWorkContext.CurrentVendor` internally. Converging on **caller-supplied `storeId` parameters is wrong for Vendor** (vendor scope isn't a store id at all) — converge on **DI-injected `IAdminDataScope<Product>` inside the service**, matching what `BaseProductController` already does, and remove the `storeId` parameters entirely. This changes the public interface — every call site found in Task 8 must be updated in the same commit as the interface change to keep the build green (do this task before, or interleaved with, whichever Task 8 rows call an affected method — recommend doing Task 9 immediately after Task 8's `#region Product list / create / edit / delete`-adjacent rows are done, since `PrepareProductListModel`/`PrepareProductsModel` are used there).
-
-- [ ] **Step 1: List every interface method with a `storeId` parameter**
-
-From the interface diff (already gathered for this plan):
-```
-PrepareProductModel(ProductModel, Product, bool, bool) // excludeProperties: keep 4-arg, see Task 7 Step 1
-PrepareTierPriceModel(ProductModel.TierPriceModel, string storeId = "")
-PrepareProductListModel(string storeId = "")
-PrepareAddRequiredProductModel(string storeId = "")
-PrepareRelatedProductModel(string storeId = "")
-PrepareSimilarProductModel(string storeId = "")
-PrepareBundleProductModel(string storeId = "")
-PrepareCrossSellProductModel(string storeId = "")
-PrepareRecommendedProductModel(string storeId = "")
-PrepareAssociatedProductModel(string storeId = "")
-PrepareBulkEditListModel(string storeId = "")
-PrepareTierPriceModel(Product, string storeId = "")
-PrepareAssociateProductToAttributeValueModel(string storeId = "")
-```
-Also reconcile the three non-storeId signature mismatches found in the diff:
-```
-OutOfStockNotifications(Product, ProductModel, int) // AdminShared vs OutOfStockNotifications(Product, int) // Vendor — extra ProductModel param, verify whether Vendor's body needs it or genuinely doesn't
-UpdateProductSpecificationAttributeModel(Product, ProductSpecificationAttribute, ...) // AdminShared vs (ProductSpecificationAttribute, ...) // Vendor — extra Product param
-```
-These two need their bodies read (not just signatures) during this task — read `src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs` at the matching method names to see whether the omitted parameter is actually unused or silently sourced from elsewhere (e.g. re-fetched inside the method).
-
-- [ ] **Step 2: Remove `storeId` from every method above in `IProductViewModelService.cs`**
-
-Example (repeat pattern for all 13 methods):
-```csharp
-// before
-Task<ProductListModel> PrepareProductListModel(string storeId = "");
-// after
-Task<ProductListModel> PrepareProductListModel();
-```
-
-- [ ] **Step 3: Add `IAdminDataScope<Product> scope` to the service's primary constructor and rewrite `PrepareProductListModel`**
-
-```csharp
-public virtual async Task<ProductListModel> PrepareProductListModel()
-{
- var model = new ProductListModel();
- var storeId = scope.DefaultStoreId ?? "";
-
- model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = " " });
- foreach (var s in (await storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
-
- model.AvailableWarehouses.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = " " });
- foreach (var wh in await warehouseService.GetAllWarehouses(storeId))
- model.AvailableWarehouses.Add(new SelectListItem { Text = wh.Name, Value = wh.Id });
-
- model.AvailableProductTypes = enumTranslationService.ToSelectList(ProductType.SimpleProduct, false).ToList();
- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "0" });
-
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SearchPublished.All"), Value = " " });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SearchPublished.PublishedOnly"), Value = "1" });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SearchPublished.UnpublishedOnly"), Value = "2" });
-
- // Admin/Store show "Show on homepage" (value 3); Vendor's current copy omits it entirely (vendors can't
- // feature products on the homepage — a real capability difference, not a naming difference). Gate it:
- if (scope.ResourceKeyPrefix != "Vendor")
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SearchPublished.ShowOnHomePage"), Value = "3" });
-
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Catalog.Products.List.SearchPublished.MarkAsNew"), Value = "4" });
-
- return model;
-}
-```
-
-Note the `if (scope.ResourceKeyPrefix != "Vendor")` gate: this is a real capability difference (found by reading both bodies for this plan — Vendor's method has no "Show on homepage" option at all, Admin/Store do), not just a resource-prefix difference. Using `ResourceKeyPrefix` as the gate condition here is a shortcut that works today (only Vendor differs) but is semantically about capability, not localization — if a fourth host is ever added, replace this with a proper `bool CanFeatureOnHomepage` on `IAdminDataScope<Product>` rather than continuing to overload `ResourceKeyPrefix` for behavior gating. Leave a comment saying so.
-
-Also drop the `model.AvailableStores` population entirely when `scope is VendorProductDataScope`-equivalent (Vendor's original method has no store dropdown at all — vendors don't pick stores). Since `DefaultStoreId` is `null` for Vendor already, `storeId` will be `""` for Vendor same as Admin — that would incorrectly populate the stores dropdown for Vendor. Add an explicit capability flag instead of overloading `DefaultStoreId is null` (which is also true for Admin, where the dropdown *should* show): introduce a fourth member on `IAdminDataScope<TEntity>` — `bool ShowStoreSelector { get; }` (`true` for Admin, `true` for Store, `false` for Vendor) — go back to Task 1-4 and add it now:
-```csharp
-// IAdminDataScope<TEntity> addition:
-bool ShowStoreSelector { get; }
-// GlobalAdminDataScope: => true; StoreAdminDataScope: => true; VendorProductDataScope: => false;
-```
-Update Task 1-4's tests to cover this new member (one assertion each) before continuing.
-
-- [ ] **Step 4: Update the two call sites already migrated in Task 7 (`BaseProductController.List()`)**
-
-```csharp
-// before (Task 7)
-var model = await productViewModelService.PrepareProductListModel(scope.DefaultStoreId ?? "");
-// after
-var model = await productViewModelService.PrepareProductListModel();
-```
-
-- [ ] **Step 5: Run the full Admin service test suite**
-
-Run: `dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~ProductViewModelServiceTests"`
-Expected: existing `PrepareProductListModel` tests need updating for the new no-arg signature — update them to construct the service with a mocked `IAdminDataScope<Product>` (three variants: default/global, store-scoped, vendor-scoped) instead of passing a `storeId` string, and add a case asserting the homepage option and store dropdown are absent when the mock reports `ResourceKeyPrefix == "Vendor"` / `ShowStoreSelector == false`.
-
-- [ ] **Step 6: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs src/Web/Grand.Web.AdminShared/Services/GlobalAdminDataScope.cs src/Web/Grand.Web.AdminShared/Services/StoreAdminDataScope.cs src/Web/Grand.Web.AdminShared/Services/VendorProductDataScope.cs src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs src/Tests/Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs src/Tests/*/Services/*DataScopeTests.cs
-git commit -m "Unify IProductViewModelService onto IAdminDataScope<Product>, drop storeId params; add ShowStoreSelector (ARCH-001 Phase 1)"
-```
-
-This will not build yet — `src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs` still implements the *old* Vendor-only `IProductViewModelService` (different interface, different namespace) and hasn't been touched. It stays broken/unreferenced until Task 12 deletes it. Confirm the build error is scoped to that one file (`dotnet build Grand.Web.AdminShared.csproj` should succeed on its own) before committing.
-
----
-
-## Task 10: Reconcile the remaining ~29 `ProductViewModelService` methods
-
-Same per-row discipline as Task 8: one method (or tightly-coupled small group, e.g. the three attribute-value overloads) per row, each read in both AdminShared and Vendor, differences resolved via `scope`, tested, committed independently.
-
-**Files (per row):**
-- Modify: `src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs`
-- Modify: `src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs` (drop any remaining `storeId` param for that method)
-- Modify (when the row drops a `storeId` param): `src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs` — grep for the method name and update every call site the same way Task 9 did for `PrepareProductListModel`.
-- Test: `src/Tests/Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs`
-- Test (when a call site changed): `src/Tests/Grand.Web.Admin.Tests/Controllers/BaseProductControllerTests.cs`
-- Read: `src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs` at the matching method (method names are shared — same name, different arity/body — locate with `grep -n "MethodName" src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs`).
-
-**Checklist (from the AdminShared method list; each unchecked row still has a `storeId` param or an unverified arity mismatch with Vendor per Task 9 Step 1):**
-- [ ] `PrepareAddProductAttributeCombinationModel`
-- [ ] `PrepareTierPriceModel(ProductModel.TierPriceModel, storeId)` — drop `storeId`
-- [ ] `PrepareProductAttributeValueModel(Product, ...)`
-- [ ] `PrepareProductModel(ProductModel, Product, bool, bool)` — resolve the 4-arg/3-arg `excludeProperties` mismatch flagged in Task 7 Step 1
-- [ ] `PrepareProductReviewModel`
-- [ ] `PrepareProductsModel`
-- [ ] `PrepareProducts(ProductListModel)`
-- [ ] `PrepareAddRequiredProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareProductModel(DataSourceRequest-ish overload at line 816)`
-- [ ] `PrepareProductCategoryModel`
-- [ ] `PrepareProductCollectionModel`
-- [ ] `PrepareRelatedProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareSimilarProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareBundleProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareCrossSellProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareRecommendedProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareAssociatedProductModel(storeId)` — drop `storeId`
-- [ ] `PrepareBulkEditListModel(storeId)` — drop `storeId`
-- [ ] `PrepareBulkEditProductModel` — **hard prerequisite, not optional:** Vendor's original implementation (`src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs`) passes `vendorId: contextAccessor.WorkContext.CurrentVendor.Id` into the underlying `SearchProducts` call, vendor-scoping the bulk-edit grid; AdminShared's version and `BulkEditListModel` have no vendor-id field/parameter at all. `BaseProductController.BulkEditSelect` (Task 8 row 15, already migrated) routes to AdminShared's unfiltered version — this is fine today only because Vendor is not yet subclassed onto `BaseProductController`. **Task 11 must not wire Vendor's `ProductController` onto `BaseProductController` until this method gains vendor-scoped filtering** (e.g. via `scope.ApplyScope` on the underlying query, or an injected filter callback) — doing so first would silently let any vendor see every vendor's products in the bulk-edit grid. Flag this row's completion as blocking Task 11, not merely a nice-to-have cleanup.
-- [ ] `PrepareTierPriceModel(Product, storeId)` — drop `storeId`
-- [ ] `PrepareBidMode`
-- [ ] `PrepareProductAttributeMappingModel` (4 overloads at lines 1365/1379/1392/1526 — AdminShared has one more overload than Vendor per the interface diff; confirm which one and whether Vendor needs it)
-- [ ] `PrepareProductAttributeMappingModels`
-- [ ] `PrepareProductAttributeConditionModel`
-- [ ] `PrepareProductAttributeValueModel` (2 more overloads at 1715/1798)
-- [ ] `PrepareProductAttributeValueModels`
-- [ ] `PrepareAssociateProductToAttributeValueModel(storeId)` — drop `storeId`
-- [ ] `PrepareProductAttributeCombinationModel`
-- [ ] `PrepareProductPicturesModel`
-- [ ] `PrepareProductPictureModel`
-- [ ] `PrepareProductSpecificationAttributeModel`
-- [ ] `OutOfStockNotifications` — resolve the `ProductModel` param mismatch flagged in Task 9 Step 1
-- [ ] `UpdateProductSpecificationAttributeModel` — resolve the `Product` param mismatch flagged in Task 9 Step 1
-- [ ] `InsertProductModel`, `UpdateProductModel`, `DeleteProduct`, `DeleteSelected` — confirm identical between AdminShared/Vendor already (likely candidates for "no change needed", but verify, don't assume)
-
-- [ ] **Step 1 (repeat per row): read both bodies, resolve differences, update interface + implementation + tests, run tests, commit**
-
-```bash
-dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~ProductViewModelServiceTests"
-git add src/Web/Grand.Web.AdminShared/Services/ProductViewModelService.cs src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs src/Tests/Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs
-git commit -m "Reconcile <MethodName> in ProductViewModelService (ARCH-001 Phase 1)"
-```
-
-- [ ] **Step 2: After all rows are checked off, confirm no `storeId` parameters remain**
-
-Run: `grep -n "storeId" src/Web/Grand.Web.AdminShared/Interfaces/IProductViewModelService.cs`
-Expected: no matches (or only local variables inside method bodies that read `scope.DefaultStoreId`, not parameters).
-
----
-
-## Task 11: Convert the three host `ProductController`s to thin subclasses
-
-**Blocking prerequisite (added after Task 8 row 15's review):** do not subclass Vendor's `ProductController` onto `BaseProductController` until Task 10's `PrepareBulkEditProductModel` row is done and confirmed to preserve vendor-scoped filtering on the bulk-edit grid — see that row's note. Wiring Vendor on first would silently expose every vendor's products in `BulkEditSelect`'s grid to every other vendor. Admin and Store have no equivalent gap and can be subclassed independently of this prerequisite. **Status: satisfied as of Task 10 (`ae5a6d187`)** — `PrepareBulkEditProductModel` now vendor-scopes via `IAdminDataScope<TEntity>.DefaultVendorId`, reviewed and confirmed unbypassable.
-
-**Second blocking prerequisite (added after Task 10's review, opus):** `InsertRelatedProductModel`/`InsertSimilarProductModel`/`InsertBundleProductModel`/`InsertCrossSellProductModel`/`InsertRecommendedProductModel` in `Grand.Web.AdminShared/Services/ProductViewModelService.cs` do not filter `SelectedProductIds` by ownership before inserting mapping rows — Vendor's original `InsertRelatedProductModel` does (`if (product == null || !HasAccessToProduct(product)) continue;`). This gap is inert today only because Vendor isn't yet subclassed onto `BaseProductController`; it goes live the moment this task wires Vendor in, letting a vendor map another vendor's products into their own related/similar/bundle/cross-sell/recommended lists. Add the same per-id `scope.HasAccess` filter (the pattern already used for `AssociatedProductAddPopup` in Task 8 row 9) to all five `Insert*ProductModel` methods in `ProductViewModelService.cs` as part of this task, before or immediately after wiring Vendor's controller — verify with a test asserting a not-owned id is silently dropped, not inserted.
-
-**Risk note (added after Task 10's review):** `InsertProductPicture` in AdminShared's service never sets `IsDefault`; Vendor's original sets `IsDefault = product.ProductPictures.Any()` (reads as inverted/likely-buggy in the original, but is nonetheless a behavior change for the Vendor host once wired). Confirm intentionally during this task's Vendor smoke-test rather than discovering it post-merge.
-
-**Files:**
-- Modify (rewrite, shrink): `src/Web/Grand.Web.Admin/Controllers/ProductController.cs`
-- Modify (rewrite, shrink): `src/Web/Grand.Web.Store/Controllers/ProductController.cs`
-- Modify (rewrite, shrink): `src/Web/Grand.Web.Vendor/Controllers/ProductController.cs`
-
-**Interfaces:**
-- Consumes: `BaseProductController` (Tasks 7-8, now complete with all 24 regions).
-
-- [ ] **Step 1: Replace Admin's controller**
-
-```csharp
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Interfaces.Common.Directory;
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Web.AdminShared.Controllers;
-using Grand.Web.AdminShared.Interfaces;
-using Grand.Web.Common.Localization;
-using Grand.Domain.Catalog;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Grand.Web.Admin.Controllers;
-
-[Area(Constants.AreaAdmin)]
-public class ProductController(
- IProductViewModelService productViewModelService,
- IProductService productService,
- IInventoryManageService inventoryManageService,
- ILanguageService languageService,
- ITranslationService translationService,
- IProductReservationService productReservationService,
- IAuctionService auctionService,
- IDateTimeService dateTimeService,
- IPermissionService permissionService,
- IEnumTranslationService enumTranslationService,
- IAdminDataScope<Product> scope)
- : BaseProductController(productViewModelService, productService, inventoryManageService, languageService,
- translationService, productReservationService, auctionService, dateTimeService, permissionService,
- enumTranslationService, scope);
-```
-
-(Fix the exact `using`s/namespaces for `IInventoryManageService`, `IProductReservationService`, `IAuctionService`, `IPermissionService`, `IEnumTranslationService` by copying them from the current file's `using` block before deleting it — don't re-guess namespaces not already confirmed in this plan.)
-
-- [ ] **Step 2: Replace Store's controller the same way, plus the `EditWarningCheck` override**
-
-```csharp
-namespace Grand.Web.Store.Controllers;
-
-[Area(Constants.AreaStore)]
-public class ProductController(/* same params as Admin */) : BaseProductController(/* same args */)
-{
- protected override void EditWarningCheck(Product product)
- {
- if (!product.LimitedToStores || (product.LimitedToStores && product.Stores.Count > 1))
- Warning(TranslationService.GetResource("Admin.Catalog.Products.Permissions"));
- }
-}
-```
-Re-derive the exact condition from the original Store code at `src/Web/Grand.Web.Store/Controllers/ProductController.cs:184-194` (reproduced in Task 7's Step 1 table) rather than retyping from memory — the original condition is unusual (it warns when NOT limited, or when limited AND accessible AND multi-store) and easy to get backwards. `TranslationService` needs to be exposed as a `protected` member on `BaseProductController` (it's currently a primary-constructor parameter, which C# does not expose to derived classes by name — add `protected ITranslationService TranslationService => translationService;` to `BaseProductController` in this step, or store a `protected readonly` field instead of a primary-constructor parameter for any member a subclass needs to reference).
-
-- [ ] **Step 3: Replace Vendor's controller the same way**
-
-No `EditWarningCheck` override needed (Vendor's original code has no equivalent branch).
-
-- [ ] **Step 4: Build all three hosts**
-
-Run:
-```
-dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
-dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj
-dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj
-```
-Expected: Vendor still fails — it's still registering `Grand.Web.Vendor.Interfaces.IProductViewModelService` (old interface) rather than AdminShared's, and its own `ProductViewModelService` class still exists. That's resolved in Task 12; if Admin and Store also fail, stop and fix before proceeding (they should build clean at this point).
-
-- [ ] **Step 5: Commit (Admin + Store only; hold Vendor's controller change until Task 12 makes it buildable)**
-
-```bash
-git add src/Web/Grand.Web.Admin/Controllers/ProductController.cs src/Web/Grand.Web.Store/Controllers/ProductController.cs src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs
-git commit -m "Reduce Admin and Store ProductController to thin BaseProductController subclasses (ARCH-001 Phase 1)"
-```
-
-Vendor's rewritten controller from Step 3 stays as an uncommitted working-tree change until Task 12.
-
----
-
-## Task 12: Delete Vendor's duplicate service and interface, finish Vendor's DI wiring
-
-**Files:**
-- Delete: `src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs`
-- Delete: `src/Web/Grand.Web.Vendor/Interfaces/IProductViewModelService.cs`
-- Modify: Vendor's `Startup` DI registration file (found in Task 5 Step 1) — repoint `IProductViewModelService` registration to `Grand.Web.AdminShared.Services.ProductViewModelService` / `Grand.Web.AdminShared.Interfaces.IProductViewModelService`
-- Modify: any other Vendor file referencing `Grand.Web.Vendor.Interfaces.IProductViewModelService` or `Grand.Web.Vendor.Models.Catalog.*` types that moved — find with Step 1
-
-**Interfaces:**
-- Consumes: `Grand.Web.AdminShared.Interfaces.IProductViewModelService` / `.Services.ProductViewModelService` (Tasks 9-10, now fully reconciled).
-
-**Addendum — Vendor's field-level FluentValidation validators (added after Task 8 row 20's review):** once Vendor's controllers bind to AdminShared's model types instead of its own (this task), Vendor-specific validators registered against the old Vendor model types — e.g. `Grand.Web.Vendor/Validators/Catalog/ProductAttributeValueModelValidator.cs`, which validates `Grand.Web.Vendor.Models.Catalog.ProductModel.ProductAttributeValueModel`'s Name/Quantity/ColorSquares/ImageSquares fields — become dead code: nothing binds the type they validate anymore. This is a field-level validation gap, not an ownership one (ownership is already covered by `scope.HasAccess`, added in Task 8). Before this task is done, grep `src/Web/Grand.Web.Vendor/Validators/` for every validator targeting a type this task's model-unification retires, and confirm AdminShared's equivalent validator (if one exists) is registered for the Vendor host too — check `AdminShared/Startup/StartupApplication.cs`'s FluentValidation registration for whether it already scans all consuming assemblies or needs an explicit add.
-
-- [ ] **Step 1: Find every remaining reference to the old Vendor-local types**
-
-Run:
-```
-grep -rln "Grand.Web.Vendor.Interfaces.IProductViewModelService\|Grand.Web.Vendor.Services.ProductViewModelService" src/Web/Grand.Web.Vendor --include=*.cs
-grep -rln "using Grand.Web.Vendor.Interfaces;" src/Web/Grand.Web.Vendor/Controllers/ProductController.cs
-```
-
-- [ ] **Step 2: Delete the two files**
-
-```bash
-git rm src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs
-git rm src/Web/Grand.Web.Vendor/Interfaces/IProductViewModelService.cs
-```
-
-- [ ] **Step 3: Update DI registration and every file found in Step 1 to reference AdminShared's interface/namespace instead**
-
-Swap `using Grand.Web.Vendor.Interfaces;` → `using Grand.Web.AdminShared.Interfaces;` and `AddScoped<Grand.Web.Vendor.Interfaces.IProductViewModelService, ...>()` → `AddScoped<IProductViewModelService, ProductViewModelService>()` (AdminShared's), matching how Admin/Store already register it (check their `Startup` files for the exact existing line to mirror).
-
-- [ ] **Step 4: Build Vendor**
-
-Run: `dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj`
-Expected: succeeds now.
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add -A
-git commit -m "Delete Vendor's duplicate ProductViewModelService/interface, use AdminShared's (ARCH-001 Phase 1)"
-```
-
----
-
-## Task 13: Consolidate characterization tests, delete superseded per-host duplicates
-
-**Status update (added after Task 11/12's reviews):** Admin's and Store's per-host
-`ProductControllerTests.cs` were already fully deleted during Task 11 (they no longer compiled against
-the new thin-subclass constructor) and replaced with routing/attribute-only coverage
-(`ProductControllerAttributesTests.cs` in each of `Grand.Web.Admin.Tests`/`Grand.Web.Store.Tests`, plus
-`Grand.Web.Store.Tests/Controllers/ProductControllerTests.cs` for the `EditWarningCheck` hook) — Steps
-1-2 below are already done for those two hosts; only Vendor's equivalent remains.
-
-**Additional files, added after Task 12's review (opus) found them:**
-- Delete: `src/Web/Grand.Web.Vendor/Models/Catalog/*.cs` (ProductModel.cs, ProductAttributeCombinationModel.cs, ProductAttributeConditionModel.cs, ProductSpecificationAttributeModel.cs, IProductValidVendor.cs, BulkEditListModel.cs, BulkEditProductModel.cs, CopyProductModel.cs, ProductAttributeModel.cs, ProductListModel.cs, ProductReviewModel.cs) — orphaned since Task 12 repointed `_ViewImports.cshtml` to AdminShared's models; confirmed nothing in `src/Web` still binds them except the files below.
-- Delete: `src/Web/Grand.Web.Vendor/Mapper/ProductProfile.cs`, `src/Web/Grand.Web.Vendor/Extensions/ProductsMappingExtensions.cs` — also orphaned; the latter defines `ToModel`/`ToEntity` extension methods returning the dead Vendor models, which would silently shadow if anything ever called them again, so delete rather than leave as inert.
-- Modify: `src/Tests/Grand.Mapping.Tests/Vendor/VendorMappingTests.cs` — also binds `Grand.Web.Vendor.Models.Catalog`; will fail to compile once the above are deleted. Trim/delete its Product-related cases the same way as the controller test files, or delete the file outright if nothing else in it survives.
-
-**Files:**
-- Modify/trim: `src/Tests/Grand.Web.Vendor.Tests/Controllers/ProductControllerTests.cs`
-- Delete: `src/Tests/Grand.Web.Vendor.Tests/Services/ProductViewModelServiceTests.cs` (superseded by `Grand.Web.Admin.Tests/Services/ProductViewModelServiceTests.cs`, which now covers all scope variants per Tasks 9-10)
-
-**Interfaces:** none new — this task only removes now-redundant test coverage and confirms the replacement (`BaseProductControllerTests`, extended `ProductViewModelServiceTests`) covers the same cases.
-
-- [ ] **Step 1: For each of the three per-host `ProductControllerTests.cs`, identify which test cases exercised logic that now lives in `BaseProductController`**
-
-Any test asserting scope/access-check behavior (e.g. "Edit returns RedirectToList when product belongs to another store") is now covered by `BaseProductControllerTests` (Task 7 Step 3, extended through Task 8). Any test asserting host-specific routing/area/authorization-attribute behavior only (e.g. "controller has `[Area(\"Admin\")]`") stays in the per-host file, since `BaseProductController` doesn't carry that attribute.
-
-- [ ] **Step 2: Trim each per-host test file down to routing/attribute-only cases**
-
-Remove the now-duplicated scope/business-logic cases; keep a small smoke test confirming the subclass resolves via DI and inherits the base actions, e.g.:
-```csharp
-[TestMethod]
-public void ProductController_IsBaseProductController()
-{
- Assert.IsInstanceOfType<BaseProductController>(CreateController());
-}
-```
-
-- [ ] **Step 3: Delete the superseded Vendor service test file**
-
-```bash
-git rm src/Tests/Grand.Web.Vendor.Tests/Services/ProductViewModelServiceTests.cs
-```
-
-- [ ] **Step 4: Run every Product-related test across all three test projects**
-
-Run:
-```
-dotnet test src/Tests/Grand.Web.Admin.Tests --filter "FullyQualifiedName~Product"
-dotnet test src/Tests/Grand.Web.Store.Tests
-dotnet test src/Tests/Grand.Web.Vendor.Tests --filter "FullyQualifiedName~Product"
-```
-Run `Grand.Web.Store.Tests` unfiltered — see the note in Task 0 about `AutoMapperConfig`'s static init living in `PaymentControllerTests`; a `~Product` filter on this project produces a false failure unrelated to this plan's changes.
-
-Expected: all PASS.
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add -A
-git commit -m "Trim per-host Product tests to routing-only, consolidate scope tests into BaseProductControllerTests (ARCH-001 Phase 1)"
-```
-
----
-
-## Task 14: Full-solution verification
-
-**Files:** none — verification only.
-
-- [ ] **Step 1: Full solution build**
-
-Run: `dotnet build GrandNode.sln`
-Expected: Build succeeded, 0 errors.
-
-- [ ] **Step 2: Full test run for the three web test projects**
-
-Run:
-```
-dotnet test src/Tests/Grand.Web.Admin.Tests
-dotnet test src/Tests/Grand.Web.Store.Tests
-dotnet test src/Tests/Grand.Web.Vendor.Tests
-```
-Expected: all PASS. Per `project_test_suite_flaky_parallel` (project memory), run each project individually rather than via a single solution-wide `dotnet test` — the full-solution parallel run is known to flake on unrelated Customers/Marketing/Messages suites.
-
-- [ ] **Step 3: Line-count sanity check against the ARCH-001 baseline**
-
-Run: `wc -l src/Web/Grand.Web.Admin/Controllers/ProductController.cs src/Web/Grand.Web.Store/Controllers/ProductController.cs src/Web/Grand.Web.Vendor/Controllers/ProductController.cs src/Web/Grand.Web.AdminShared/Controllers/BaseProductController.cs`
-Expected: the three host controllers are each roughly 20-40 lines (matching `LoginController`'s shape); `BaseProductController.cs` accounts for the bulk of what was previously ~2500 lines ×3.
-
-- [ ] **Step 4: Manual smoke test (if a local Kestrel instance is available per `reference_running_the_storefront`)**
-
-Log into each of the three admin panels and open Product → List → Edit → Save for one existing product per host, confirming no runtime DI resolution errors and that store/vendor scoping still restricts what's visible (a Store-scoped or Vendor-scoped login should not see or be able to open another store's/vendor's product).
-
-- [ ] **Step 5: Update the ARCH-001 project memory**
-
-Edit `project_arch001_triple_admin_duplication.md` (memory file) to note Phase 1 (Product controller + service) is complete, Phase 2 (views) is a separate follow-up plan, and that the pattern is now proven for future entities (Order, Category, Collection).
-
-- [ ] **Step 6: Final commit**
-
-```bash
-git add -A
-git commit -m "ARCH-001 Phase 1 complete: Product controller and service consolidated into AdminShared"
-```
diff --git a/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md b/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md
deleted file mode 100644
index 2acb2f8b9..000000000
--- a/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md
+++ /dev/null
@@ -1,717 +0,0 @@
-# ARCH-001 Phase 2 (View Consolidation) Implementation Plan
-
-> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. Task 4 is a per-file checklist (one `.cshtml` filename per row) — when using subagent-driven-development, dispatch one subagent per checklist row, not one subagent for the whole task.
-
-**Goal:** Delete the three duplicated copies of `Product/*.cshtml` (51 Admin /
-51 Store / 49 Vendor files) by moving one canonical copy of each into
-`Grand.Web.AdminShared`, discovered at runtime via a `ViewLocationExpander`
-fallback, with host-specific overrides kept only where a real functional
-difference exists.
-
-**Architecture:** `Grand.Web.AdminShared` becomes a Razor Class Library
-(`Sdk="Microsoft.NET.Sdk.Razor"`, `AddRazorSupportForMvc=true`) — the same
-mechanism this repo's plugins already use to ship views inside their own DLL.
-`Grand.Web.Common/View/ViewLocationExpander.cs` gets a second, independent
-branch: when the executing controller derives from a type in
-`Grand.Web.AdminShared.Controllers`, it appends `/Views/{1}/{0}.cshtml` to the
-end of the candidate view locations, so a host's own override (checked first
-by `RazorViewEngine`) always wins over the AdminShared fallback.
-
-**Tech Stack:** ASP.NET Core MVC Razor views, C# 13, MSTest (existing test
-stack, unaffected by this plan — no `.cs` production logic changes, only
-`.cshtml` moves and one `.csproj`/one `.cs` file).
-
-**Spec:** `docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md`
-
-## Global Constraints
-
-- No new automated view-rendering test infrastructure (spec, "Non-goals") —
- verification is `dotnet build` plus a manual/characterization pass.
-- A view with a real functional difference between hosts stays a whole-file,
- host-specific override — never split into shared-skeleton-plus-partial
- (spec, "Non-goals" — YAGNI unless a specific file proves otherwise during
- Task 4, decided per-file, not planned in advance).
-- Every moved view must lose its hardcoded `asp-area="@Constants.AreaAdmin"`-
- style literal (host-specific `Constants` class, not visible from
- `Grand.Web.AdminShared`) in favor of `ViewContext.RouteData.Values["area"]`,
- and every moved resource-key lookup that differs by host
- (`Admin.*`/`Vendor.*`) must route through the injected
- `Scope.ResourceKeyPrefix` (spec, sections 3, 3b).
-- Only `Product` views. No other entity's views move in this plan.
-- Follow existing repo conventions: `.ai/standards/razor-frontend.md` for
- Razor/tag-helper conventions, `.ai/skills/admin-area-changes.md` for
- admin-facing view changes.
-
----
-
-## Task 0: Baseline
-
-**Files:** none — verification only.
-
-- [ ] **Step 1: Confirm the branch builds and tests pass before touching views**
-
-Run:
-```
-dotnet build GrandNode.sln
-dotnet test src/Tests/Grand.Web.Admin.Tests
-dotnet test src/Tests/Grand.Web.Store.Tests
-dotnet test src/Tests/Grand.Web.Vendor.Tests
-```
-Expected: Build succeeded, all tests PASS. If anything fails here, stop and
-fix or report before starting Task 1 — this is the safety net Phase 1 left in
-place (per project memory `project_arch001_triple_admin_duplication`, Phase 1
-verified green on 2026-08-17).
-
-- [ ] **Step 2: Record the current per-host view file counts**
-
-Run:
-```
-find src/Web/Grand.Web.Admin/Areas/Admin/Views/Product -iname "*.cshtml" | wc -l
-find src/Web/Grand.Web.Store/Areas/Store/Views/Product -iname "*.cshtml" | wc -l
-find src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product -iname "*.cshtml" | wc -l
-```
-Expected: 51, 51, 49 — matches the spec's baseline. If different, the repo has
-moved since this plan was written; stop and reconcile the plan's Task 4
-checklist against the actual current file list before proceeding.
-
----
-
-## Task 1: `Grand.Web.AdminShared` becomes a Razor Class Library
-
-**Files:**
-- Modify: `src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj`
-
-**Interfaces:** none — no consumers exist yet (no `.cshtml` files added until
-Task 3).
-
-- [ ] **Step 1: Change the SDK and add Razor-for-MVC support**
-
-Current file:
-```xml
-<Project Sdk="Microsoft.NET.Sdk">
- <Import Project="..\..\Build\Grand.Common.props" />
- <PropertyGroup>
- <ImplicitUsings>enable</ImplicitUsings>
- </PropertyGroup>
- ...
-```
-
-Change the opening `<Project>` tag and `<PropertyGroup>`:
-```xml
-<Project Sdk="Microsoft.NET.Sdk.Razor">
- <Import Project="..\..\Build\Grand.Common.props" />
- <PropertyGroup>
- <ImplicitUsings>enable</ImplicitUsings>
- <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
- </PropertyGroup>
- ...
-```
-Leave the rest of the file (the `ProjectReference`/`PackageReference`
-`ItemGroup`s) unchanged.
-
-- [ ] **Step 2: Build to confirm the SDK swap alone doesn't break anything**
-
-Run:
-```
-dotnet build src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj
-dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
-dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj
-dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj
-```
-Expected: all succeed. `Sdk="Microsoft.NET.Sdk.Razor"` with no `.cshtml` files
-present yet just adds Razor tooling to the build; it does not require any view
-to exist.
-
-- [ ] **Step 3: Commit**
-
-```bash
-git add src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj
-git commit -m "Convert Grand.Web.AdminShared to a Razor Class Library (ARCH-001 Phase 2)"
-```
-
----
-
-## Task 2: `ViewLocationExpander` fallback branch
-
-**Files:**
-- Modify: `src/Web/Grand.Web.Common/View/ViewLocationExpander.cs`
-- Test: `src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs` (new file)
-- Test: `src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs` (new file)
-
-**Interfaces:**
-- Produces: `ViewLocationExpander.ExpandViewLocations` gains a second,
- independent branch. The classification logic is extracted as an internal
- static method `IsAdminSharedController(ActionDescriptor)` so it's unit
- testable without a full `ViewLocationExpanderContext`.
-
-- [ ] **Step 1: Check the existing test project's conventions**
-
-Run: `find src/Tests/Grand.Web.Common.Tests -iname "*.cs" | head -5` to confirm
-the project exists and see its namespace/test-attribute conventions (MSTest,
-per `.ai/knowledge/tests.md`). If `View/` doesn't exist as a subfolder yet,
-create it alongside the test file in Step 2.
-
-- [ ] **Step 2: Write the failing tests**
-
-C# allows only one namespace per file when using the file-scoped
-`namespace X;` form — the fake types standing in for a real
-`Grand.Web.AdminShared.Controllers`-namespaced base controller (this test
-project has no reference to `Grand.Web.AdminShared`, so a real
-`BaseProductController` isn't available; only the namespace string matters
-for `IsAdminSharedController`) go in their own file, block-scoped:
-
-Create `src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs`:
-
-```csharp
-// Stands in for a real Base*Controller living in Grand.Web.AdminShared.Controllers
-// (this test project has no reference to Grand.Web.AdminShared) — only the
-// namespace string matters to ViewLocationExpander.IsAdminSharedController.
-namespace Grand.Web.AdminShared.Controllers
-{
- public abstract class FakeBaseController { }
-}
-
-namespace Grand.Web.Common.Tests.View
-{
- public class FakeAdminSharedSubclass : Grand.Web.AdminShared.Controllers.FakeBaseController { }
-
- public class FakeUnrelatedController { }
-}
-```
-
-Create `src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs`:
-
-```csharp
-using Grand.Web.Common.View;
-using Microsoft.AspNetCore.Mvc.Abstractions;
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Grand.Web.Common.Tests.View;
-
-[TestClass]
-public class ViewLocationExpanderTests
-{
- private static ControllerActionDescriptor DescriptorFor(Type controllerType) =>
- new() { ControllerTypeInfo = controllerType.GetTypeInfo() };
-
- [TestMethod]
- public void IsAdminSharedController_TypeDerivesFromAdminSharedControllersNamespace_ReturnsTrue()
- {
- var descriptor = DescriptorFor(typeof(FakeAdminSharedSubclass));
- Assert.IsTrue(ViewLocationExpander.IsAdminSharedController(descriptor));
- }
-
- [TestMethod]
- public void IsAdminSharedController_UnrelatedType_ReturnsFalse()
- {
- var descriptor = DescriptorFor(typeof(FakeUnrelatedController));
- Assert.IsFalse(ViewLocationExpander.IsAdminSharedController(descriptor));
- }
-
- [TestMethod]
- public void IsAdminSharedController_NonControllerActionDescriptor_ReturnsFalse()
- {
- var descriptor = new ActionDescriptor();
- Assert.IsFalse(ViewLocationExpander.IsAdminSharedController(descriptor));
- }
-}
-```
-
-Note: `ControllerTypeInfo.GetTypeInfo()` requires `using System.Reflection;` —
-add it to the test file's usings.
-
-- [ ] **Step 3: Run tests to verify they fail**
-
-Run: `dotnet test src/Tests/Grand.Web.Common.Tests --filter "FullyQualifiedName~ViewLocationExpanderTests"`
-Expected: FAIL (compile error — `IsAdminSharedController` doesn't exist yet,
-and it isn't `internal`-visible to the test project yet either — see Step 4's
-`InternalsVisibleTo` note).
-
-- [ ] **Step 4: Make `Grand.Web.Common`'s internals visible to its test project**
-
-Run: `grep -n "InternalsVisibleTo" src/Web/Grand.Web.Common/Grand.Web.Common.csproj`
-to check whether this is already wired. If not, add to
-`src/Web/Grand.Web.Common/Grand.Web.Common.csproj`'s first `<ItemGroup>` (or a
-new one):
-```xml
-<ItemGroup>
- <InternalsVisibleTo Include="Grand.Web.Common.Tests" />
-</ItemGroup>
-```
-
-- [ ] **Step 5: Implement the expander branch**
-
-Replace `src/Web/Grand.Web.Common/View/ViewLocationExpander.cs` in full:
-
-```csharp
-using Grand.Web.Common.Themes;
-using Microsoft.AspNetCore.Mvc.Abstractions;
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.AspNetCore.Mvc.Razor;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace Grand.Web.Common.View;
-
-public class ViewLocationExpander : IViewLocationExpander
-{
- private const string ThemeKey = "Theme";
- private const string AdminSharedFallbackLocation = "/Views/{1}/{0}.cshtml";
- private const string AdminSharedControllersNamespace = "Grand.Web.AdminShared.Controllers";
-
- public void PopulateValues(ViewLocationExpanderContext context)
- {
- var themeContextFactory =
- context.ActionContext.HttpContext.RequestServices.GetRequiredService<IThemeContextFactory>();
- var themeContext = themeContextFactory.GetThemeContext(context.AreaName ?? "");
- var themeName = themeContext?.GetCurrentTheme();
- if (!string.IsNullOrEmpty(themeName))
- context.Values[ThemeKey] = themeContext.GetCurrentTheme();
- }
-
- public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
- IEnumerable<string> viewLocations)
- {
- if (context.Values.TryGetValue(ThemeKey, out _))
- {
- var viewFactory = context.ActionContext.HttpContext.RequestServices.GetRequiredService<IViewFactory>();
- viewFactory.GetViewPath(context.AreaName ?? "", ref viewLocations);
- }
-
- if (IsAdminSharedController(context.ActionContext.ActionDescriptor))
- viewLocations = viewLocations.Append(AdminSharedFallbackLocation);
-
- return viewLocations;
- }
-
- /// <summary>Whether the executing action's controller type (or any base type) lives in
- /// Grand.Web.AdminShared.Controllers. Generic by design — no per-entity base-controller
- /// list to maintain: the moment a future Base*Controller (Order, Category, ...) lands in
- /// that namespace, its host subclasses get the AdminShared view fallback automatically.</summary>
- internal static bool IsAdminSharedController(ActionDescriptor descriptor)
- {
- if (descriptor is not ControllerActionDescriptor cad) return false;
- for (var t = cad.ControllerTypeInfo.AsType(); t is not null; t = t.BaseType)
- if (t.Namespace == AdminSharedControllersNamespace)
- return true;
- return false;
- }
-}
-```
-
-- [ ] **Step 6: Run tests to verify they pass**
-
-Run: `dotnet test src/Tests/Grand.Web.Common.Tests --filter "FullyQualifiedName~ViewLocationExpanderTests"`
-Expected: PASS (3/3).
-
-- [ ] **Step 7: Build the three hosts**
-
-Run:
-```
-dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
-dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj
-dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj
-```
-Expected: all succeed. The branch is inert until Task 3 gives it a real
-`BaseProductController`-derived action and a view to fall back to — this step
-only confirms the expander itself compiles and doesn't regress the existing
-`ThemeKey` branch (still present, untouched).
-
-- [ ] **Step 8: Commit**
-
-```bash
-git add src/Web/Grand.Web.Common/View/ViewLocationExpander.cs src/Web/Grand.Web.Common/Grand.Web.Common.csproj src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs
-git commit -m "Add AdminShared view fallback branch to ViewLocationExpander (ARCH-001 Phase 2)"
-```
-
----
-
-## Task 3: Shared `_ViewImports.cshtml` / `_ViewStart.cshtml` + worked pilot view
-
-This is the template every remaining file in Task 4 follows. Do this one file
-fully and correctly before touching any other.
-
-**Files:**
-- Create: `src/Web/Grand.Web.AdminShared/Views/_ViewImports.cshtml`
-- Create: `src/Web/Grand.Web.AdminShared/Views/_ViewStart.cshtml`
-- Create: `src/Web/Grand.Web.AdminShared/Views/Product/TierPriceCreatePopup.cshtml`
-- Delete: `src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml`
-- Delete: `src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml`
-- Delete: `src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml`
-
-**Interfaces:**
-- Consumes: `IAdminDataScope<Product>` (Phase 1, DI-registered per host),
- `LocService`/`IEnumTranslationService` (existing, see each host's own
- `_ViewImports.cshtml`).
-
-- [ ] **Step 1: Create the shared `_ViewImports.cshtml`**
-
-```cshtml
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
-@addTagHelper *, Grand.Web.Common
-
-@using System.Globalization
-@using Microsoft.AspNetCore.Http.Extensions
-@using Microsoft.AspNetCore.Mvc.ViewFeatures
-@using System.Text
-@using Grand.SharedKernel.Extensions
-@using Grand.Infrastructure
-@using Grand.Domain.Common
-@using Grand.Domain.Catalog
-@using Grand.Domain.Directory
-@using Grand.Web.Common
-@using Grand.Web.Common.Extensions
-@using Grand.Web.Common.Localization
-@using Grand.Web.AdminShared.Models.Catalog
-@using Grand.Web.AdminShared.Interfaces
-
-@inject LocService Loc
-@inject IEnumTranslationService EnumTranslationService
-@inject IAdminDataScope<Product> Scope
-```
-
-- [ ] **Step 2: Create the shared `_ViewStart.cshtml`**
-
-```cshtml
-@{
- var area = Context.GetRouteValue("area")?.ToString();
- Layout = $"~/Areas/{area}/Views/Shared/_{area}Layout.cshtml";
-}
-```
-
-This resolves each host's own layout by name (`_AdminLayout.cshtml`,
-`_StoreLayout.cshtml`, `_VendorLayout.cshtml`) using the current request's
-area — see spec section 3a for why `_ViewStart.cshtml` must live here rather
-than relying on each host's own (it won't be found for a view resolved
-through the AdminShared fallback location).
-
-- [ ] **Step 3: Read the three current copies to confirm the diff shape**
-
-Run:
-```
-diff -u src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml
-diff -u src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml
-```
-Expected (confirmed 2026-08-17): Store's copy differs from Admin's only in
-`asp-area="@Constants.AreaStore"` vs `@Constants.AreaAdmin`. Vendor's copy
-differs in that plus two `Loc["Vendor.Catalog.Products.TierPrices.AddNew"]`
-vs `Loc["Admin.Catalog.Products.TierPrices.AddNew"]` resource-key swaps. No
-other content differs across all three — this is a pure "trivial unify" case
-(spec section 4, row 1).
-
-- [ ] **Step 4: Write the unified view**
-
-Create `src/Web/Grand.Web.AdminShared/Views/Product/TierPriceCreatePopup.cshtml`:
-
-```cshtml
-@model ProductModel.TierPriceModel
-
-@{
- Layout = "";
-
- //page title
- ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.TierPrices.AddNew"];
- var area = ViewContext.RouteData.Values["area"]?.ToString();
-}
-
-<form id="TierPriceCreatePopup" asp-area="@area" asp-controller="Product" asp-action="TierPriceCreatePopup"
- asp-route-ProductId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["ProductId"])"
- asp-route-btnId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["btnId"])"
- asp-route-formId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["formId"])">
-
- <div class="row">
- <div class="col-md-12">
- <div class="x_panel light form-fit">
- <div class="x_title">
- <div class="caption">
- <i class="fa fa-cube"></i>
- @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.TierPrices.AddNew"]
- </div>
- </div>
- <div class="x_content form">
- <partial name="Partials/CreateOrUpdateTierPrice" model="Model"/>
- </div>
- </div>
- </div>
- </div>
- <script>
- var mfp = $.magnificPopup.instance;
- $("#TierPriceCreatePopup").submit(function (e) {
- e.preventDefault();
- var form = $(this);
- var url = form.attr('action');
- $.ajax({
- type: "POST",
- url: url,
- data: form.serialize(),
- success: function (data) {
- if (data == "") {
- mfp.close();
- } else {
- $.magnificPopup.open({
- items: {
- src: data,
- type: 'inline'
- },
- callbacks: {
- open: function () {
- $('.mfp-wrap').removeAttr('tabindex');
- }
- }
- });
- }
- $('#btnRefreshTierPrices').click();
- }
- });
- });
- </script>
-</form>
-```
-
-Note `Layout = ""` (a popup with no chrome) — this file happens not to depend
-on the new `_ViewStart.cshtml` from Step 2 at all, but every other Task 4 row
-that omits `Layout` does, so `_ViewStart.cshtml` must exist before any row
-that relies on it is migrated. It's created in this task so it's already in
-place for all of Task 4.
-
-- [ ] **Step 5: Delete the three host copies**
-
-```bash
-git rm src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml
-git rm src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml
-git rm src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml
-```
-
-- [ ] **Step 6: Build all three hosts**
-
-Run:
-```
-dotnet build src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj
-dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
-dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj
-dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj
-```
-Expected: all succeed. A missing `@inject` or bad `@using` in the new
-`_ViewImports.cshtml`/the view itself shows up here as a Razor compile error
-(this project does compile-time Razor validation as part of `dotnet build`,
-not only at first request).
-
-- [ ] **Step 7: Manual smoke check**
-
-If a local Kestrel instance is available (per project memory
-`reference_running_the_storefront`), open the Admin panel, edit a product,
-open its Tier prices tab, click "Add new" — confirm the popup renders with
-the correct title, submits, and closes. Repeat once for Store and once for
-Vendor (each showing the resource key under their own prefix). If no local
-instance is available, note this in the commit message body and rely on the
-build success + Task 4/5's aggregate manual pass to catch it.
-
-- [ ] **Step 8: Commit**
-
-```bash
-git add -A
-git commit -m "Migrate TierPriceCreatePopup to AdminShared, pilot for view consolidation (ARCH-001 Phase 2)"
-```
-
----
-
-## Task 4: Migrate the remaining Product views
-
-Same per-row discipline as Phase 1's Task 8/10: one filename per row, each
-read across every host that has it, classified, migrated (or left as a
-host-specific override), verified with a build, and committed independently.
-Follow Task 3's template exactly: same `_ViewImports.cshtml` (already in
-place, don't recreate it), same "read all present variants → diff → resolve
-`asp-area` literal via `ViewContext.RouteData.Values["area"]` and resource
-prefix via `Scope.ResourceKeyPrefix` → write one file in
-`Grand.Web.AdminShared/Views/Product/` (or its `Partials/` subfolder, matching
-each file's current subfolder) → delete host copies → build → commit" cycle.
-
-**Files (per row):**
-- Create: `src/Web/Grand.Web.AdminShared/Views/Product/<name>.cshtml` (or
- `Partials/<name>.cshtml`) — unless the row's classification is "keep as
- host override", in which case no AdminShared file is created.
-- Delete: the file's copy in each host that currently has it (2 or 3 of
- `src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/...`,
- `src/Web/Grand.Web.Store/Areas/Store/Views/Product/...`,
- `src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/...`) — unless kept as
- an override, in which case only the non-kept hosts' copies (if any
- duplicate the kept one byte-for-byte) are candidates for deletion; if in
- doubt, keep all host copies that currently exist for an override row and
- note the ambiguity in the commit message rather than guessing.
-
-**Known baseline (2026-08-17), `diffAS`/`diffAV` = number of changed diff
-lines, Admin-vs-Store / Admin-vs-Vendor, `diff -U0` line count; `presence` =
-which hosts currently have the file (Vendor is missing two files entirely).
-Recompute for any file if the repo has drifted since — this table is a
-starting hint, not a substitute for reading the actual current files:**
-
-| # | File | Presence | diffAS | diffAV | Starting hint |
-|---|---|---|---|---|---|
-| 1 | `AssociateProductToAttributeValuePopup.cshtml` | A,S,V | 18 | 34 | small-medium diff, likely area+prefix only — verify |
-| 2 | `AssociatedProductAddPopup.cshtml` | A,S,V | 20 | 34 | same shape as #1 |
-| 3 | `AttributeCombinationPopup.cshtml` | A,S,V | 10 | 131 | large Admin/Vendor diff — read closely, may have a real difference |
-| 4 | `BulkEdit.cshtml` | A,S,V | 21 | 47 | check for the vendor-scoped bulk-edit grid difference (Phase 1 Task 10 note) |
-| 5 | `BundleProductAddPopup.cshtml` | A,S,V | 20 | 30 | same shape as #1 |
-| 6 | `Create.cshtml` | A,S,V | 2 | 14 | small — likely trivial unify (relies on the shared `_ViewStart.cshtml` for Layout) |
-| 7 | `CrossSellProductAddPopup.cshtml` | A,S,V | 18 | 34 | same shape as #1 |
-| 8 | `Edit.cshtml` | A,S,V | 4 | 26 | small-medium — check the Store `EditWarningCheck` hook (Phase 1) has a matching view-side warning banner |
-| 9 | `List.cshtml` | A,S,V | 141 | 110 | **real functional difference** — Admin has a bulk export/import/delete panel and Store/Vendor filter panel drops `SearchStoreId`/`SearchVendorId`; likely candidate for host-specific override per host, not a single unified file |
-| 10 | `Partials/CreateOrUpdate.Additional.cshtml` | A,S,V | 2 | 94 | Admin/Store trivial; Vendor differs a lot — read before assuming unifiable |
-| 11 | `Partials/CreateOrUpdate.AssociatedProducts.cshtml` | A,S,V | 10 | 32 | medium |
-| 12 | `Partials/CreateOrUpdate.Bids.cshtml` | A,S,V | 6 | 22 | small-medium |
-| 13 | `Partials/CreateOrUpdate.BundleProducts.cshtml` | A,S,V | 10 | 32 | medium |
-| 14 | `Partials/CreateOrUpdate.Calendar.cshtml` | A,S,V | 12 | 60 | medium-large |
-| 15 | `Partials/CreateOrUpdate.Categories.cshtml` | A,S,V | 12 | 54 | medium-large |
-| 16 | `Partials/CreateOrUpdate.Collections.cshtml` | A,S,V | 12 | 44 | medium |
-| 17 | `Partials/CreateOrUpdate.CrossSells.cshtml` | A,S,V | 8 | 22 | small-medium |
-| 18 | `Partials/CreateOrUpdate.Discounts.cshtml` | A,S only | 0 | n/a | **Admin/Store byte-identical, Vendor has no such tab at all** — unify Admin+Store into one AdminShared file; Vendor simply never requests it (Phase 1's Vendor tab set already excludes Discounts) |
-| 19 | `Partials/CreateOrUpdate.Documents.cshtml` | A,S only | 8 | n/a | Admin/Store small diff, Vendor has no such tab — same treatment as #18 once Admin/Store diff is resolved |
-| 20 | `Partials/CreateOrUpdate.Info.cshtml` | A,S,V | 26 | 160 | **large diff** — read very closely, likely has real per-host fields (e.g. vendor selector shown/hidden) |
-| 21 | `Partials/CreateOrUpdate.Inventory.cshtml` | A,S,V | 0 | 20 | Admin/Store byte-identical; Vendor differs — likely unifiable with a `Scope`-driven conditional |
-| 22 | `Partials/CreateOrUpdate.Pictures.cshtml` | A,S,V | 8 | 28 | small-medium |
-| 23 | `Partials/CreateOrUpdate.Prices.cshtml` | A,S,V | 8 | 83 | medium-large, Vendor differs a lot |
-| 24 | `Partials/CreateOrUpdate.ProductAttributes.TabAttributeCombinations.cshtml` | A,S,V | 12 | 40 | medium |
-| 25 | `Partials/CreateOrUpdate.ProductAttributes.TabAttributes.cshtml` | A,S,V | 20 | 42 | medium |
-| 26 | `Partials/CreateOrUpdate.ProductAttributes.cshtml` | A,S,V | 0 | 10 | Admin/Store byte-identical |
-| 27 | `Partials/CreateOrUpdate.ProductPrices.cshtml` | A,S,V | 8 | 49 | medium |
-| 28 | `Partials/CreateOrUpdate.PurchasedWithOrders.cshtml` | A,S,V | 6 | 52 | medium |
-| 29 | `Partials/CreateOrUpdate.Recommended.cshtml` | A,S,V | 8 | 22 | small-medium |
-| 30 | `Partials/CreateOrUpdate.RelatedProducts.cshtml` | A,S,V | 10 | 26 | small-medium |
-| 31 | `Partials/CreateOrUpdate.Reviews.cshtml` | A,S,V | 6 | 20 | small-medium |
-| 32 | `Partials/CreateOrUpdate.SEO.cshtml` | A,S,V | 0 | 4 | tiny — near-trivial |
-| 33 | `Partials/CreateOrUpdate.SimilarProducts.cshtml` | A,S,V | 10 | 26 | small-medium |
-| 34 | `Partials/CreateOrUpdate.SpecificationAttributes.cshtml` | A,S,V | 10 | 26 | small-medium |
-| 35 | `Partials/CreateOrUpdate.cshtml` | A,S,V | 0 | 60 | Admin/Store byte-identical; Vendor differs (likely the tab list itself — fewer tabs for Vendor, e.g. no Discounts/Documents) — read closely, this is the tab-container partial |
-| 36 | `Partials/CreateOrUpdateProductAttributeValue.cshtml` | A,S,V | 2 | 10 | small — likely trivial |
-| 37 | `Partials/CreateOrUpdateTierPrice.cshtml` | A,S,V | 0 | 22 | Admin/Store byte-identical; Vendor differs |
-| 38 | `Partials/ProductAttributes.cshtml` | A,S,V | 0 | 0 | **byte-identical across all three hosts already** — trivial unify, no conditionals needed |
-| 39 | `ProductAttributeConditionPopup.cshtml` | A,S,V | 2 | 16 | small |
-| 40 | `ProductAttributeMappingPopup.cshtml` | A,S,V | 2 | 10 | small — same shape as Task 3's pilot |
-| 41 | `ProductAttributeValidationRulesPopup.cshtml` | A,S,V | 2 | 8 | small — same shape as Task 3's pilot |
-| 42 | `ProductAttributeValueCreatePopup.cshtml` | A,S,V | 2 | 6 | small — same shape as Task 3's pilot, diff confirmed 2026-08-17 |
-| 43 | `ProductAttributeValueEditPopup.cshtml` | A,S,V | 2 | 6 | small — same shape as Task 3's pilot |
-| 44 | `ProductPicturePopup.cshtml` | A,S,V | 2 | 8 | small |
-| 45 | `ProductSpecAttrPopup.cshtml` | A,S,V | 4 | 10 | small |
-| 46 | `RecommendedProductAddPopup.cshtml` | A,S,V | 20 | 34 | same shape as #1 |
-| 47 | `RelatedProductAddPopup.cshtml` | A,S,V | 18 | 32 | same shape as #1 |
-| 48 | `RequiredProductAddPopup.cshtml` | A,S,V | 18 | 52 | medium |
-| 49 | `SimilarProductAddPopup.cshtml` | A,S,V | 20 | 32 | same shape as #1 |
-| 50 | `TierPriceEditPopup.cshtml` | A,S,V | 2 | 6 | small — same shape as Task 3's pilot |
-
-(`TierPriceCreatePopup.cshtml` is row 0, done in Task 3.)
-
-- [ ] **Step 1 (repeat per row): read, classify, migrate (or override), build, commit**
-
-For each row:
-1. Read every present host's copy of the file in full.
-2. Classify per spec section 4:
- - Byte-identical or differs only by area literal / resource prefix already
- covered by `Scope.ResourceKeyPrefix` → write one file in AdminShared,
- following Task 3's pattern (`ViewContext.RouteData.Values["area"]` for
- the area, `Scope.ResourceKeyPrefix` for resource keys), delete host
- copies.
- - Differs by a capability flag Phase 1 already introduced on the view
- model (e.g. a bool controlling whether a field renders) → one file with
- an `@if (Model.SomeFlag) { ... }`, delete host copies.
- - Real functional difference → leave every existing host copy exactly
- where it is; do not touch it, do not create an AdminShared file for it.
- `RazorViewEngine`'s host-location-first ordering (Task 2) means these
- continue rendering exactly as before with zero code change — this row
- is only a documented "leave alone" decision, still worth its own commit
- noting why, for the audit trail.
-3. Build: `dotnet build src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj && dotnet build src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj && dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj && dotnet build src/Web/Grand.Web.Vendor/Grand.Web.Vendor.csproj`
-4. Commit:
-```bash
-git add -A
-git commit -m "Migrate <FileName> to AdminShared (ARCH-001 Phase 2)"
-# or, for a "leave alone" row:
-git commit -m "Keep <FileName> as host-specific override, no unification (ARCH-001 Phase 2)" --allow-empty
-```
-
-- [ ] **Step 2: After all 50 rows are checked off, confirm no orphaned host copies remain for unified files**
-
-Run:
-```
-find src/Web/Grand.Web.Admin/Areas/Admin/Views/Product src/Web/Grand.Web.Store/Areas/Store/Views/Product src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product -iname "*.cshtml" | sort
-find src/Web/Grand.Web.AdminShared/Views/Product -iname "*.cshtml" | sort
-```
-Cross-check against the row-by-row decisions recorded in commit messages —
-every file that was unified should no longer exist under any host's own
-`Views/Product/`, and every file kept as an override should exist in exactly
-the hosts that had it originally (not fewer, not more).
-
----
-
-## Task 5: Full-solution verification
-
-**Files:** none — verification only.
-
-- [ ] **Step 1: Full solution build**
-
-Run: `dotnet build GrandNode.sln`
-Expected: Build succeeded, 0 errors.
-
-- [ ] **Step 2: Full test run for the affected test projects**
-
-Run (individually, per project memory `project_test_suite_flaky_parallel` —
-not a single solution-wide `dotnet test`):
-```
-dotnet test src/Tests/Grand.Web.Common.Tests
-dotnet test src/Tests/Grand.Web.Admin.Tests
-dotnet test src/Tests/Grand.Web.Store.Tests
-dotnet test src/Tests/Grand.Web.Vendor.Tests
-```
-Expected: all PASS.
-
-- [ ] **Step 3: File-count sanity check against the ARCH-001 Phase 2 baseline**
-
-Run:
-```
-find src/Web/Grand.Web.Admin/Areas/Admin/Views/Product -iname "*.cshtml" | wc -l
-find src/Web/Grand.Web.Store/Areas/Store/Views/Product -iname "*.cshtml" | wc -l
-find src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product -iname "*.cshtml" | wc -l
-find src/Web/Grand.Web.AdminShared/Views/Product -iname "*.cshtml" | wc -l
-```
-Expected: the three host counts have dropped from the Task 0 baseline
-(51/51/49) by however many rows were unified in Task 4; `AdminShared/Views/
-Product` holds that many files (plus 1 for Task 3's pilot). The three host
-counts plus the AdminShared count, accounting for files present in more than
-one host before migration, should reconcile against Task 4's per-row log —
-if they don't, some row was migrated inconsistently; find and fix it before
-proceeding.
-
-- [ ] **Step 4: Manual smoke test**
-
-If a local Kestrel instance is available (per project memory
-`reference_running_the_storefront`): log into each of the three admin panels
-and open Product → List → Create → Edit → Save for one existing product per
-host. Confirm:
-- No `InvalidOperationException: The view '...' was not found` error for any
- action.
-- Each host's layout/chrome renders correctly (validates the `_ViewStart.cshtml`
- fix from Task 3/spec section 3a).
-- Host-specific content still appears only where expected (Admin's bulk
- export/import/delete panel on `List.cshtml`; Vendor has no
- Discounts/Documents tab).
-- Popups (tier price, product attribute value, etc.) open, submit, and close
- correctly on all three hosts.
-
-If no local instance is available, report this explicitly as unverified
-rather than claiming the pass was done.
-
-- [ ] **Step 5: Update the ARCH-001 project memory**
-
-Edit the memory file `project_arch001_triple_admin_duplication.md` (outside
-this repo, in the memory directory) to record Phase 2 complete: views
-unified, host-specific overrides count, any views deliberately left
-un-unified and why, and that the `Grand.Web.AdminShared` + `ViewLocationExpander`
-pattern is now proven end-to-end (controller, service, and view layers) and
-ready to reuse for the next entity.
-
-- [ ] **Step 6: Final commit**
-
-```bash
-git add -A
-git commit -m "ARCH-001 Phase 2 complete: Product views consolidated into AdminShared"
-```
diff --git a/docs/superpowers/specs/2026-08-16-arch001-product-consolidation-design.md b/docs/superpowers/specs/2026-08-16-arch001-product-consolidation-design.md
deleted file mode 100644
index 33373262d..000000000
--- a/docs/superpowers/specs/2026-08-16-arch001-product-consolidation-design.md
+++ /dev/null
@@ -1,150 +0,0 @@
-# ARCH-001 — Product panel consolidation design
-
-Date: 2026-08-16
-Status: Approved, ready for implementation planning
-
-## Problem
-
-`Grand.Web.Admin`, `Grand.Web.Store`, and `Grand.Web.Vendor` each carry their own
-copy of `ProductController` (2478 / 2625 / 2584 lines) and, for the view-model
-layer, `Grand.Web.AdminShared` and `Grand.Web.Vendor` each carry their own
-`ProductViewModelService` (2571 / 2381 lines, 1768 lines of diff). The copies
-have drifted too far to merge mechanically. A bug fix or security patch in the
-product editor currently requires three independent edits, and history shows
-that requirement gets missed (commits #754, #765 fixed antiforgery handling in
-some panels but not all). Full finding recorded in project memory
-`project_arch001_triple_admin_duplication.md`.
-
-This spec covers **only the `Product` vertical** (`ProductController` +
-`ProductViewModelService` + `Product` views) as the first, highest-value slice
-of ARCH-001. It does not attempt to generalize to every entity yet, though the
-core abstraction is named and shaped so Order/Category/Collection can adopt it
-later without redesign.
-
-## Existing precedent
-
-`Grand.Web.AdminShared/Controllers/BaseLoginController.cs` already implements
-this exact pattern: an abstract base controller in AdminShared, with three
-21-line subclasses (`Grand.Web.Admin/Store/Vendor/Controllers/LoginController.cs`)
-that add only `[Area(...)]` and pass constructor args through. This design
-follows that precedent at Product's scale.
-
-Recent groundwork already in place (as of 2026-08-16):
-- Characterization tests exist for all three `ProductController`s
- (`src/Tests/Grand.Web.{Admin,Store,Vendor}.Tests/Controllers/ProductControllerTests.cs`)
- and for both `ProductViewModelService`s (`Grand.Web.Admin.Tests` covers
- AdminShared's, `Grand.Web.Vendor.Tests` covers Vendor's).
-- #786 deduped Store's `ProductController` access checks onto a single
- `CanAccessProduct` helper.
-- #785 deduped Vendor's access checks similarly.
-- #788 synced Vendor's `ProductViewModelService` to AdminShared's
- primary-constructor style, reducing incidental diff noise before a merge.
-
-These give a safety net for a direct migration (no parallel-run / feature flag
-needed — chosen deliberately over a flagged rollout given the test coverage
-already in place).
-
-## Current access-scope patterns (what `IAdminDataScope` must replace)
-
-- **Admin**: no filtering — global access to all products.
-- **Store** (`Grand.Web.Store/Controllers/ProductController.cs`): scattered
- direct reads of `_contextAccessor.WorkContext.CurrentCustomer.StaffStoreId`,
- used both to filter lists/queries and as a default value written onto new/
- edited products (`model.StoreId`, `model.Stores`, list search filters).
-- **Vendor** (`Grand.Web.Vendor/Controllers/ProductController.cs`): entity-level
- checks via `_contextAccessor.WorkContext.HasAccessToProduct(product)`,
- applied per-action rather than as a list filter.
-
-## Architecture
-
-A new abstraction in `Grand.Web.AdminShared`:
-
-```csharp
-public interface IAdminDataScope<TEntity>
-{
- Task<bool> HasAccess(TEntity entity);
- IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query);
- string? DefaultStoreId { get; } // null for Admin/Vendor, StaffStoreId for Store
-}
-```
-
-Three implementations, one per host, each registered in that host's own
-`Startup` (matching how each host registers its own services today):
-
-- `GlobalAdminDataScope<TEntity>` (Admin) — `HasAccess` always true, `ApplyScope`
- is a no-op, `DefaultStoreId` is `null`.
-- `StoreAdminDataScope<TEntity>` (Store) — wraps `StaffStoreId` filtering/
- defaulting in one place instead of the current scattered call sites.
-- `VendorAdminDataScope<TEntity>` (Vendor) — delegates to the existing
- `IWorkContext.HasAccessToProduct` (or the generalized equivalent).
-
-`DefaultStoreId` exists specifically to make today's implicit per-host
-default (Store always stamps `model.StoreId`; Admin never does) explicit and
-testable instead of an artifact of the diff.
-
-The interface is typed generically (`<TEntity>`) and named without a `Product`
-suffix so Order/Category/Collection can implement it later, but this spec
-only ships the `Product` instantiation and only what `ProductController`
-actually needs — no speculative members beyond the three above.
-
-## Phase 1 — Controller and service consolidation
-
-- `Grand.Web.AdminShared/Controllers/BaseProductController.cs`: the union of
- today's three controllers' action logic, with every `StaffStoreId`/
- `HasAccessToProduct` call site replaced by calls into the injected
- `IAdminDataScope<Product>`.
-- Three per-host `ProductController : BaseProductController` subclasses,
- reduced to `[Area(...)]` + constructor pass-through, matching
- `LoginController`.
-- `Grand.Web.AdminShared/Services/ProductViewModelService.cs` gains whatever
- Vendor's copy has that AdminShared's doesn't. Each real difference found in
- the 1768-line diff must be attributed to a scope decision (`IAdminDataScope`)
- or ported as shared behavior — never copy-pasted as a parallel branch.
- Vendor's own `Services/ProductViewModelService.cs` is deleted; Vendor starts
- consuming AdminShared's, as Store already does.
-- Existing characterization tests are the migration's correctness gate: they
- move to (or are consolidated into) `Grand.Web.AdminShared.Tests`, plus thin
- per-host tests that check only routing/authorization attributes. New unit
- tests cover the three `IAdminDataScope` implementations directly.
-- Phase 1 ships as an independently mergeable, fully working change — no
- half-migrated state, no flag.
-
-## Phase 2 — View consolidation
-
-- `Product/*.cshtml` views (51 Admin / 51 Store / 49 Vendor) move to
- `Grand.Web.AdminShared/Views/Product/`.
-- `Grand.Web.Common/View/ViewLocationExpander.cs` (today handles only the
- storefront `ThemeKey` case) gains an admin-area branch: when the executing
- controller derives from `BaseProductController`, AdminShared's view folder
- is added as a fallback location.
-- Views whose only difference is the hardcoded area string
- (`Constants.AreaAdmin`/`AreaStore`/`AreaVendor`) are unified into one
- AdminShared view using the request's current area instead.
-- Views with a real functional difference (e.g. Admin-only bulk export panel
- on `List.cshtml`) stay as host-specific overrides, resolved before the
- AdminShared fallback by the expander.
-- Phase 2 depends on Phase 1 (needs `BaseProductController` to exist as the
- branch condition) but is its own mergeable unit with its own review
- checkpoint — work can pause between phases without leaving a broken or
- half-migrated state.
-
-## Testing
-
-- Phase 1: run and green all migrated/consolidated `ProductControllerTests`
- and `ProductViewModelServiceTests` (Admin/Store/Vendor), plus new
- `IAdminDataScope` unit tests.
-- Phase 2: manual/characterization pass over rendered Product screens per
- host (List, Create, Edit, and the tabs/partials with known host-specific
- content) to confirm the expander resolves views correctly and overrides
- render where expected.
-
-## Out of scope
-
-- Any entity other than Product (Order, Category, Collection, etc.) — future
- work, enabled but not started by this spec.
-- Merging the three hosts into a single deployable app — explicitly rejected
- in the ARCH-001 finding; auth models, data scopes, and independent
- deployability stay separate.
-- A generalized `IAdminAreaContext` covering area name + capability flags —
- considered (design option C) and deferred as speculative beyond what
- Product needs today.
diff --git a/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md b/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md
deleted file mode 100644
index 48d5ec078..000000000
--- a/docs/superpowers/specs/2026-08-17-arch001-phase2-view-consolidation-design.md
+++ /dev/null
@@ -1,634 +0,0 @@
-# ARCH-001 Phase 2 — Product view consolidation design
-
-Date: 2026-08-17
-Status: Approved, ready for implementation planning
-
-## Problem
-
-Phase 1 (`docs/superpowers/specs/2026-08-16-arch001-product-consolidation-design.md`,
-implemented on branch `arch001/phase1-product-consolidation`, PR #790) consolidated
-`ProductController` and `ProductViewModelService` into `Grand.Web.AdminShared`,
-reducing each host's controller to a ~20-70 line subclass of `BaseProductController`.
-The one duplication Phase 1 explicitly deferred is views: `Grand.Web.Admin`,
-`Grand.Web.Store`, and `Grand.Web.Vendor` each still carry their own copy of
-`Product/*.cshtml` (51 / 51 / 49 files, ~9300 / ~9060 / ~8600 lines). Spot-check
-diff of `List.cshtml` (Admin vs Store) confirms the same pattern Phase 1 found in
-controllers: some files differ only in a hardcoded area string or resource-key
-prefix, others have a real functional difference (Admin's bulk export/import/
-delete panel and `SearchStoreId`/`SearchVendorId` filters are absent from Store's
-`List.cshtml`; Vendor lacks `CreateOrUpdate.Discounts.cshtml` and
-`CreateOrUpdate.Documents.cshtml` entirely).
-
-This spec covers **only the `Product` view set**, the second and final slice of
-the Phase 1/2 split already anticipated in the Phase 1 spec's "Phase 2 — View
-consolidation" section. It supersedes that section with a concrete, checked
-design.
-
-## Existing precedent
-
-Plugins in this repo already compile Razor views into their own assembly and
-have them discovered at runtime — e.g. `src/Plugins/DiscountRules.Standard/
-DiscountRules.Standard.csproj` uses `Sdk="Microsoft.NET.Sdk.Razor"` with
-`<AddRazorSupportForMvc>true</AddRazorSupportForMvc>`. Per project memory
-`reference_running_the_storefront`, "Plugin views compile into the plugin DLL."
-This is the same mechanism ASP.NET Core uses for Razor Class Libraries consumed
-via `ProjectReference` (MSBuild auto-generates a `RelatedAssembly` attribute on
-the consuming project, and `ApplicationPartManager` auto-discovers the
-referenced assembly's compiled views) — no plugin-loading machinery is needed
-for this case since `Grand.Web.AdminShared` is already a compile-time
-`ProjectReference` from all three hosts.
-
-`Grand.Web.Common/View/ViewLocationExpander.cs` already implements one
-conditional, additive branch (`ThemeKey`, for storefront theme overrides). This
-design adds a second, independent branch to the same class rather than
-introducing a new expander.
-
-## Goals
-
-- Delete the ~150-file, ~27000-line-total duplication the same way Phase 1
- deleted the controller/service duplication: one canonical copy per view,
- living in `Grand.Web.AdminShared`, with host-specific overrides only where a
- real functional difference exists.
-- No change to deployability: each host stays independently buildable and
- deployable; views arrive via the existing `ProjectReference`, not a new
- packaging or runtime-discovery mechanism.
-- Host-specific views continue to render as they do today — this is a pure
- dedup, not a UX change (aside from the deliberate, already-known Store/Vendor
- feature gaps captured in Phase 1's controller work).
-
-## Non-goals
-
-- No new automated test infrastructure. This repo has no `WebApplicationFactory`
- usage anywhere (confirmed by search) and host startup is gated on
- `DataSettingsManager.DatabaseIsInstalled()`, meaning a real integration-test
- harness would need Mongo (e.g. Testcontainers) — a project of its own. Out of
- scope here; verification stays the manual/characterization pass the Phase 1
- spec already anticipated.
-- No splitting of host-specific-difference views into shared skeleton + partial
- override. A view with a real functional difference stays a whole-file,
- host-specific override. Revisit only if a future file turns out to be >80%
- identical with one small differing block — decide per-file during migration,
- default to whole-file override (YAGNI).
-- No change to non-Product views. Order/Category/Collection view consolidation
- is future work enabled, not started, by this design (same boundary Phase 1
- drew for controllers/services).
-- No generalized `IAdminAreaContext` or view-model changes — this is a view
- file relocation plus one expander branch, nothing in `BaseProductController`
- or `ProductViewModelService` changes.
-
-## Design
-
-### 1. `Grand.Web.AdminShared` becomes a Razor Class Library
-
-Change `src/Web/Grand.Web.AdminShared/Grand.Web.AdminShared.csproj`:
-
-```xml
-<Project Sdk="Microsoft.NET.Sdk.Razor">
- <Import Project="..\..\Build\Grand.Common.props" />
- <PropertyGroup>
- <ImplicitUsings>enable</ImplicitUsings>
- <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
- </PropertyGroup>
- <!-- existing ItemGroups unchanged -->
-</Project>
-```
-
-No other project in the solution needs to change how it references AdminShared
-— the three hosts already have a `ProjectReference` to it from Phase 1.
-
-### 2. View location: `Grand.Web.AdminShared/Views/Product/*.cshtml`
-
-Not under an `Areas/` folder — AdminShared has no area of its own. The relative
-path a Razor view compiles under (`/Views/Product/List.cshtml`) becomes its
-lookup key application-wide, independent of which assembly compiled it.
-
-### 3. `ViewLocationExpander` gets a second, independent branch
-
-`src/Web/Grand.Web.Common/View/ViewLocationExpander.cs`, in
-`ExpandViewLocations`:
-
-```csharp
-public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
- IEnumerable<string> viewLocations)
-{
- if (context.Values.TryGetValue(ThemeKey, out _))
- {
- var viewFactory = context.ActionContext.HttpContext.RequestServices.GetRequiredService<IViewFactory>();
- viewFactory.GetViewPath(context.AreaName ?? "", ref viewLocations);
- }
-
- if (IsAdminSharedController(context.ActionContext.ActionDescriptor))
- viewLocations = viewLocations.Append("/Views/{1}/{0}.cshtml");
-
- return viewLocations;
-}
-
-private static bool IsAdminSharedController(ActionDescriptor descriptor)
-{
- if (descriptor is not ControllerActionDescriptor cad) return false;
- for (var t = cad.ControllerTypeInfo.AsType(); t is not null; t = t.BaseType)
- if (t.Namespace == "Grand.Web.AdminShared.Controllers")
- return true;
- return false;
-}
-```
-
-Generic namespace check, not a hardcoded `BaseProductController` reference —
-Phase 3 (Order, Category, ...) gets the fallback automatically the moment a
-`Base*Controller` lands in that namespace, with zero further change to this
-file. The `Append` (not prepend) is what makes host-specific overrides win:
-`RazorViewEngine` tries each location in order and returns the first file that
-exists, so a host's own `Areas/{Area}/Views/Product/X.cshtml` — which appears
-earlier in the default location list — always wins over the AdminShared
-fallback when both exist.
-
-The two branches (`ThemeKey` / AdminShared) are independent and additive —
-Grand.Web (storefront) has no `Grand.Web.AdminShared.Controllers`-derived
-controllers, and Admin/Store/Vendor have no theme context, so in practice at
-most one branch ever fires per request.
-
-### 3a. Layout resolution (addendum, found while drafting the pilot task)
-
-`List.cshtml`/`Create.cshtml`/`Edit.cshtml` (and most other Product views) set
-no `Layout` themselves — they inherit it from each host's own
-`Areas/{Area}/Views/_ViewStart.cshtml` (e.g.
-`src/Web/Grand.Web.Admin/Areas/Admin/Views/_ViewStart.cshtml` sets
-`Layout = Constants.Layout_Admin`). Razor's `_ViewStart.cshtml` discovery walks
-up from the **resolved logical path the view was found under**, not from the
-requesting controller's area. A view resolved through the new fallback
-location (`/Views/Product/List.cshtml`, inside `Grand.Web.AdminShared`) walks
-up `/Views/Product/` → `/Views/` → `/` looking for `_ViewStart.cshtml` there —
-it never sees `/Areas/Admin/Views/_ViewStart.cshtml`, so `Layout` would be left
-unset and the page would render with no host chrome.
-
-Fix: add `src/Web/Grand.Web.AdminShared/Views/_ViewStart.cshtml`:
-
-```cshtml
-@{
- var area = Context.GetRouteValue("area")?.ToString();
- Layout = $"~/Areas/{area}/Views/Shared/_{area}Layout.cshtml";
-}
-```
-
-The three hosts' layout files already follow this exact naming convention
-(`_AdminLayout.cshtml`, `_StoreLayout.cshtml`, `_VendorLayout.cshtml`, confirmed
-via `Constants.Layout_Admin`/`LayoutStore`/`LayoutVendor` in each host's own
-`Extensions/Constants.cs`) and stay put in each host — only `Views/Product/*`
-moves. The `~/`-rooted path resolves against the full merged view-location
-provider (all `ApplicationPart`s, including the executing host's own compiled
-views), so it finds the host's own layout correctly regardless of which
-assembly the `_ViewStart.cshtml` itself lives in.
-
-### 3b. `_ViewImports.cshtml` for the shared view folder (addendum)
-
-Each host's `Areas/{Area}/Views/_ViewImports.cshtml` brings in the tag helpers
-and `@inject`s a migrated view needs (`Loc` for resource lookups,
-`EnumTranslationService`). The tag helpers Product views actually use
-(`admin-input`, `admin-select`, `admin-label`, etc.) come from
-`@addTagHelper *, Grand.Web.Common` — already common to all three hosts'
-`_ViewImports.cshtml`, not from any host-specific tag helper assembly — so a
-single shared import file covers them. Add
-`src/Web/Grand.Web.AdminShared/Views/_ViewImports.cshtml`:
-
-```cshtml
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
-@addTagHelper *, Grand.Web.Common
-
-@using System.Globalization
-@using Microsoft.AspNetCore.Http.Extensions
-@using Microsoft.AspNetCore.Mvc.ViewFeatures
-@using System.Text
-@using Grand.SharedKernel.Extensions
-@using Grand.Infrastructure
-@using Grand.Domain.Common
-@using Grand.Domain.Catalog
-@using Grand.Domain.Directory
-@using Grand.Web.Common
-@using Grand.Web.Common.Extensions
-@using Grand.Web.Common.Localization
-@using Grand.Web.AdminShared.Models.Catalog
-@using Grand.Web.AdminShared.Interfaces
-
-@inject LocService Loc
-@inject IEnumTranslationService EnumTranslationService
-@inject IAdminDataScope<Product> Scope
-```
-
-Injecting `Scope` at the `_ViewImports` level (not per-file) means every
-migrated view gets `Scope.ResourceKeyPrefix` (for the `Admin.*`/`Vendor.*`
-resource-key split, same as `BaseProductController`'s Phase 1 pattern) and
-`ViewContext.RouteData.Values["area"]` (read per-file where an
-`asp-area="@Constants.AreaAdmin"` literal needs replacing) without repeating
-the `@inject` line in all ~50 files. If a per-file migration needs a tag
-helper or using not in this list, add it here rather than to the individual
-file, unless it's genuinely single-file-specific.
-
-### 4. Per-file migration classification
-
-For each of the ~53 distinct Product view filenames (union of the three
-hosts), read all present variants and classify:
-
-| Case | Resolution |
-|---|---|
-| Byte-identical, or differs only in a hardcoded area string / resource-key prefix already unified behind `IAdminDataScope` in Phase 1 | One file in `AdminShared/Views/Product/`, using `ViewContext.RouteData.Values["area"]` (or the equivalent existing helper) instead of a literal `Constants.AreaAdmin`/`AreaStore`/`AreaVendor`; delete the 2-3 host copies. |
-| Differs only by a capability flag Phase 1 already introduced (e.g. `Model.ShowStoreSelector`, `scope.ResourceKeyPrefix`) | One file with the existing conditional (`@if (Model.ShowStoreSelector) { ... }`); delete host copies. |
-| Real functional difference (Admin-only bulk export/import/delete panel and store/vendor search filters on `List.cshtml`; Vendor missing `Discounts`/`Documents` partials entirely) | Stays as a whole-file, host-specific override in that host's own `Areas/{Area}/Views/Product/` folder. Not moved to AdminShared. |
-
-This mirrors Phase 1's Task 8/10 discipline: one file (or a tightly-coupled
-small group, e.g. `CreateOrUpdate.*.cshtml` region partials with a shared
-parent) per checklist row, each read across all present hosts, classified,
-migrated, and committed independently — subagent-driven-development, one
-subagent per row.
-
-### 5. Verification
-
-- `dotnet build GrandNode.sln` after the RCL conversion and after each
- migration batch — a missing view at runtime is a startup-time or
- render-time failure, not a compile error, so build success alone is not
- sufficient evidence.
-- Manual/characterization pass per host (per the original Phase 1 spec's
- Testing section): List → Create → Edit → Save for an existing product,
- once per host (Admin/Store/Vendor), confirming the page renders with the
- expected host-specific content (or lack thereof) and no
- `InvalidOperationException: The view '...' was not found` error.
-- Existing MSTest suites (`Grand.Web.Admin.Tests`, `Grand.Web.Store.Tests`,
- `Grand.Web.Vendor.Tests`) stay green throughout — they don't render Razor
- views today (confirmed: no `WebApplicationFactory` usage in the repo), so
- they are a regression guard for the controller/service layer this touches
- incidentally (e.g. if a `.cshtml` move breaks a `[ViewComponent]` or model
- binding), not a substitute for the manual pass above.
-
-### 4a. Widget-zone selection: per-area partial files, not an inline `@if` (addendum, 2026-08-18)
-
-Early Task 4 batches unified views containing a widget-zone tag-helper call
-(`<vc:admin-widget widget-zone="X" .../>` vs `<vc:vendor-widget
-widget-zone="vendor_X" .../>`) using an inline conditional:
-
-```cshtml
-@if (Scope.ResourceKeyPrefix == "Vendor")
-{
- <vc:vendor-widget widget-zone="vendor_product_bulk_edit_buttons" additional-data="null"/>
-}
-else
-{
- <vc:admin-widget widget-zone="product_bulk_edit_buttons" additional-data="null"/>
-}
-```
-
-Superseded. Widget-zone selection now uses a small, per-occurrence partial
-resolved through the same host-override-wins mechanism section 3 already
-established, instead of a C# branch inside the unified file:
-
-- `src/Web/Grand.Web.AdminShared/Views/Product/Partials/WidgetZone.<Name>.cshtml`
- holds the Admin/Store-shared default: `<vc:admin-widget widget-zone="X"
- additional-data="..."/>`.
-- `src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/WidgetZone.<Name>.cshtml`
- holds Vendor's override: `<vc:vendor-widget widget-zone="vendor_X"
- additional-data="..."/>`.
-- The parent unified view calls `<partial name="Partials/WidgetZone.<Name>"
- model="..."/>` in place of the old `@if` block. Admin and Store naturally
- fall through to the AdminShared default (no host-specific file needed for
- them, since they share it); Vendor's own `Areas/Vendor/...` copy is found
- first by `RazorViewEngine` and wins, exactly like any other host override
- under section 3 — no new expander logic needed.
-- `<Name>` is a short, occurrence-specific PascalCase name derived from the
- zone-name pair with the common `product_`/`vendor_product_` prefix and any
- `vendor_` prefix stripped (e.g. `product_bulk_edit_buttons` /
- `vendor_product_bulk_edit_buttons` → `WidgetZone.BulkEditButtons.cshtml`;
- `product_details_bids_top` / `vendor_product_details_bids_top` →
- `WidgetZone.Bids.Top.cshtml`). Pick a name that reads clearly next to its
- sibling occurrences in the same parent file (e.g. `Bids.Top`/`Bids.Bottom`
- for the two zones inside `CreateOrUpdate.Bids.cshtml`).
-
-Rationale: `Scope.ResourceKeyPrefix`-branching was already established for
-genuinely mixed content (a whole tab present in some hosts, per section 3's
-`CreateOrUpdate.cshtml` case) where no other mechanism fits cleanly. For
-widget-zone selection specifically — a single self-contained tag-helper call
-repeated at ~20+ sites — a per-area file keeps each host's markup physically
-separate and lets the existing view-resolution precedence do the selection,
-rather than growing every unified file's branch count. This also means a
-future widget-zone-only change to one host never touches the shared parent
-file at all.
-
-All files already unified under the old inline-`@if` pattern get retrofitted
-to this one in the same implementation pass that introduces it (tracked in
-the plan's Task 4 as a one-time batch), so the codebase never carries both
-patterns side by side once that pass lands.
-
-## Out of scope
-
-- Automated view-rendering tests (`WebApplicationFactory`, Testcontainers-backed
- Mongo) — noted above as a real gap, but its own project; revisit separately
- if the manual pass proves too costly to repeat as Phase 3+ lands.
-- Any entity other than Product.
-- Merging the three hosts into one deployable app (same standing rejection as
- Phase 1).
-
-## 5. Post-review corrections (2026-08-18)
-
-A final whole-branch review inspected the *compiled* assemblies and the combined
-`Grand.Web` host, and found two render-time regressions that neither the diff nor
-`dotnet build` could show. Both are fixed on this branch. **Sections 2, 3a, 3b and
-4a above are superseded on the two points below** — read this section as the
-current truth.
-
-### 5.1 Shared views live under `/Views/AdminShared/…`, not `/Views/…` (supersedes section 2)
-
-Section 2 asserted that a view's compiled path "becomes its lookup key
-application-wide" without checking that key against existing occupancy. A Razor
-view path is global across *every* `ApplicationPart`, and `Grand.Web` — the
-combined host — references `Grand.Web.{Admin,Store,Vendor}` and therefore
-transitively loads AdminShared's views alongside its own storefront views. Two
-real collisions existed: `/Views/_ViewStart.cshtml` (AdminShared's admin-layout
-resolver vs. the storefront's `Layout = "_Layout"`) and
-`/Views/Product/Partials/ProductAttributes.cshtml` (admin `ProductModel` partial
-vs. the storefront product-details partial). One silently shadows the other and
-the loser fails at render time; which one wins depends on application-part order.
-
-Corrected layout:
-
-- `src/Web/Grand.Web.AdminShared/Views/AdminShared/{Controller}/*.cshtml`
-- `src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml`
-- `src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewStart.cshtml`
-- `ViewLocationExpander.AdminSharedFallbackLocation` = `/Views/AdminShared/{1}/{0}.cshtml`
-
-The `_ViewStart` ancestor walk still resolves
-(`/Views/AdminShared/Product/X.cshtml` → `/Views/AdminShared/_ViewStart.cshtml`)
-and host-override precedence is unchanged.
-
-**Rule for Phase 3 and later:** every shared entity folder goes under
-`Views/AdminShared/`. The `AdminShared` segment is owned by no other project, so
-`Order/`, `Vendor/`, `Page/`, `Blog/`, `News/` and `Catalog/` — all of which
-already exist under `src/Web/Grand.Web/Views/` — cannot collide.
-
-### 5.2 Widget-zone defaults live in `Grand.Web.Admin`, not AdminShared (amends section 4a)
-
-Section 4a placed the Admin/Store-shared widget-zone default in
-`AdminShared/Views/Product/Partials/WidgetZone.<Name>.cshtml`. That does not
-work: `<vc:admin-widget>` binds to `AdminWidgetViewComponent` in
-`Grand.Web.Admin`, and Razor binds tag helpers **at compile time** from the
-compiling project's `@addTagHelper` set. `Grand.Web.AdminShared` only adds
-`Grand.Web.Common`, so all 44 widget-zone calls in the moved views compiled to
-literal `<vc:admin-widget …/>` markup — no compile error, no warning, no runtime
-exception, just dead zones and a stray custom element per site. Verified in the
-built assembly: 44 literal `<vc:` strings in `Grand.Web.AdminShared.dll` and zero
-`AdminWidgetViewComponent` references.
-
-Corrected placement, per widget zone:
-
-| File | Content |
-|---|---|
-| `Grand.Web.Admin/Areas/Admin/Views/Product/Partials/WidgetZone.<Name>.cshtml` | the real `<vc:admin-widget widget-zone="X" …/>` |
-| `Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/WidgetZone.<Name>.cshtml` | the real `<vc:vendor-widget widget-zone="vendor_X" …/>` (unchanged) |
-| `Grand.Web.AdminShared/Views/AdminShared/Product/Partials/WidgetZone.<Name>.cshtml` | an empty `@* … *@` placeholder, which Store falls through to |
-
-The parent shared view still calls `<partial name="Partials/WidgetZone.<Name>"
-model="…"/>`; selection still happens purely through the section-3 override
-precedence. The empty AdminShared placeholder preserves Store's exact
-pre-existing behaviour (Store has no widget component and never rendered these
-zones) while making it deliberate instead of accidental.
-
-**Rule:** a Razor construct that binds to a *host's* tag helper or view component
-cannot live in `Grand.Web.AdminShared`. Only markup whose tag helpers come from
-`Grand.Web.Common` is shareable. The cheap mechanical check is that
-`Grand.Web.AdminShared.dll` must contain zero literal `<vc:` strings.
-
-The two files that carried inline widget calls
-(`CreateOrUpdate.Discounts.cshtml`, `CreateOrUpdate.Documents.cshtml`) stay in
-AdminShared — Store needs both tabs — with the calls extracted into
-`WidgetZone.{Discounts,Documents}.{Top,Bottom}` pairs. Their previously deferred
-hardcoded `Loc["Admin.…"]` keys were templated to
-`Loc[$"{Scope.ResourceKeyPrefix}.…"]` in the same pass.
-
-### 5.3 Other corrections in the same wave
-
-- `RoutedProductDataScope` now fails **closed**: `"Admin"` is an explicit arm and
- an unrecognized or missing `area` throws `InvalidOperationException` instead of
- resolving to the unscoped `GlobalAdminDataScope`. Covered by new
- `RoutedProductDataScopeTests` in `Grand.Web.Admin.Tests`.
-- `AdminShared/Views/AdminShared/_ViewImports.cshtml` documents the two
- host-detection idioms (`Scope.ResourceKeyPrefix` for Admin+Store vs. Vendor;
- the `area` route value when Admin must be told apart from Store) so later
- phases do not add a third.
-- `_ViewStart.cshtml` guards a null/empty `area` instead of composing
- `~/Areas//Views/Shared/_Layout.cshtml`.
-
-### 5.4 Still outstanding
-
-The manual per-host smoke pass from the Design section's "5. Verification" has **not** been run. It must cover
-all three standalone hosts *and* the combined `grand-web` host, and must be run
-against a non-`Development` environment — `AddRazorRuntimeCompilation()` is
-enabled only when `ASPNETCORE_ENVIRONMENT == Development`, so a Development run
-resolves views differently from a production build.
-
-## 6. Retire `Scope.ResourceKeyPrefix != "Vendor"` as a content-gating idiom (addendum, 2026-08-18)
-
-### Problem
-
-Section 4a/5.2 replaced widget-zone `@if (Scope.ResourceKeyPrefix == "Vendor")` branches with
-per-host partial files. Six sites doing the same string comparison for a different purpose —
-hiding or altering a block of markup for Vendor, not selecting a widget component — were left
-behind:
-
-- `Views/AdminShared/Product/Partials/CreateOrUpdate.cshtml:7,132` — gates the Documents tab
- (combined with a permission check) and the UserFields tab.
-- `Views/AdminShared/Product/Partials/CreateOrUpdateTierPrice.cshtml:31` — gates the
- Store/CustomerGroup form-group pair.
-- `Views/AdminShared/Product/Partials/CreateOrUpdate.Additional.cshtml:71` — gates the whole
- `group-downloads` section.
-- `Views/AdminShared/Product/Partials/CreateOrUpdate.Categories.cshtml:100-107,109-122` and the
- equivalent lines in `CreateOrUpdate.Collections.cshtml` — one branch swaps a Kendo Grid
- `template:` between a clickable link (Admin/Store) and plain text (Vendor); a second branch
- adds/omits the whole `IsFeaturedProduct` column definition.
-- `Grand.Web.AdminShared/Services/ProductViewModelService.cs:577` — C#, not Razor; gates the
- "Show on homepage" search-filter option. Already flagged by a comment left on that line in the
- prior pass recommending exactly the fix below.
-
-`ResourceKeyPrefix` is documented (Interfaces/IAdminDataScope.cs) as a localization-key-building
-string ("Admin" for Global and Store, "Vendor" for Vendor) — using it as a two-way behavior switch
-overloads a property with one declared purpose to also do another, undeclared one. It works only
-by accident (today there are exactly two distinct prefix values, and they happen to line up with
-the Vendor/non-Vendor split every one of these six sites needs).
-
-A companion check confirmed `Admin.*`/`Vendor.*` resource values under `catalog.products.*` are
-byte-identical wherever both exist (0 of ~230 shared keys differ; the only 7 differing pairs in the
-whole resource file are under `reports.*`, outside this design's scope). No change to the resource
-files follows from this — deleting or merging `Vendor.*` entries would need an upgrade migration
-(they're seeded to Mongo, not read live from XML) and would silently drop any store owner's custom
-translations of those keys. Out of scope here. `ResourceKeyPrefix` keeps its one declared job:
-building `Loc[$"{Scope.ResourceKeyPrefix}...."]` keys. Nothing branches on it anymore after this
-section.
-
-### Resolution, per site
-
-Same override-wins mechanism as section 4a, applied to three shapes of content difference:
-
-1. **Presence/absence of a self-contained block** (a `<tabstrip-item>`, a `<div class="form-group">`
- pair, a whole `<div id="group-...">` section, a Kendo column-definition object): extract the
- block into `Partials/<Name>.cshtml`, called unconditionally from the parent. AdminShared's copy
- holds the real content (Admin+Store); a same-named file under
- `Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/<Name>.cshtml` is empty (an `@* ... *@`
- comment, mirroring the empty-placeholder precedent from section 5.2) and wins for Vendor through
- ordinary view-location precedence. No C# conditional remains in the parent file.
- - `CreateOrUpdate.cshtml` → `Partials/Tab.Documents.cshtml`, `Partials/Tab.UserFields.cshtml`
- (Documents additionally still needs the `ManageDocuments` permission check — that check moves
- into the AdminShared partial itself, since it's an authorization concern, not a host-shape
- one; Vendor's empty override doesn't need it, it never had the tab).
- - `CreateOrUpdateTierPrice.cshtml` → `Partials/TierPrice.StoreScope.cshtml`.
- - `CreateOrUpdate.Additional.cshtml` → `Partials/Additional.Downloads.cshtml`.
- - `CreateOrUpdate.Categories.cshtml` / `CreateOrUpdate.Collections.cshtml` (the
- `IsFeaturedProduct` column) → `Partials/Categories.FeaturedColumn.cshtml` /
- `Partials/Collections.FeaturedColumn.cshtml`.
-2. **Content that differs rather than disappears** (the Kendo `template:` link-vs-plain-text
- swap): extract just the differing fragment into its own partial, both hosts get a real file.
- - `CreateOrUpdate.Categories.cshtml` → `Partials/Categories.LinkTemplate.cshtml` (AdminShared:
- `template: '<a class="k-link" href="...">#:Category#</a>'`; Vendor:
- `template: '#:Category#'`).
- - `CreateOrUpdate.Collections.cshtml` → `Partials/Collections.LinkTemplate.cshtml`, same shape.
- - `CreateOrUpdate.Reviews.cshtml` (found during implementation - not in the original six-site
- audit, which only searched for `!= "Vendor"` and missed this file's `== "Vendor"` phrasing of
- the same idiom) → `Partials/Reviews.CustomerLinkTemplate.cshtml` and
- `Partials/Reviews.TitleLinkTemplate.cshtml`, same shape, two occurrences in one file.
-3. **C# capability gate** (no partial mechanism applies outside Razor): add a named boolean to
- `IAdminDataScope<TEntity>` instead of comparing `ResourceKeyPrefix`, matching the pattern
- `ShowStoreSelector`/`DefaultVendorId` already establish for capability flags.
- - Add `bool CanFeatureOnHomepage { get; }` — `true` on `GlobalAdminDataScope<TEntity>` and
- `StoreAdminDataScope<TEntity>`, `false` on `VendorProductDataScope`.
- - `ProductViewModelService.cs:577` becomes `if (scope.CanFeatureOnHomepage)`, and the comment
- explaining the old string-comparison workaround is deleted (the workaround it warned about is
- gone).
-
-### Verification
-
-- `dotnet build GrandNode.sln`.
-- `Grand.Web.AdminShared.dll` still contains zero literal `<vc:` strings (section 5.2's check) —
- unaffected by this section, listed here only as a standing regression guard for the same class of
- compile-time tag-helper-binding mistake.
-- Manual pass: open a product's Edit page as Admin, Store owner, and Vendor. Confirm Vendor sees no
- Documents/UserFields tabs, no Store/CustomerGroup tier-price fields, no downloads section, no
- "Show on homepage" filter option, and Category/Collection grids show plain text instead of links;
- confirm Admin and Store are pixel-identical to their pre-change rendering.
-- `Grand.Web.Admin.Tests` / `Grand.Web.Store.Tests` / `Grand.Web.Vendor.Tests` stay green — the new
- `CanFeatureOnHomepage` flag is a small, direct addition to the existing
- `GlobalAdminDataScopeTests`/`StoreAdminDataScopeTests`/`VendorProductDataScopeTests` fixtures.
-
-## 7. Wire up Store's own `vc:store-widget` for Product widget zones (addendum, 2026-08-18)
-
-### Problem
-
-Section 5.2 placed an empty AdminShared placeholder at every one of the 44
-`WidgetZone.<Name>.cshtml` files with the comment "Store has no equivalent widget zone." That claim
-was checked against Store's *original* (pre-Phase-2) Product views, which is where it went wrong:
-those original files called `<vc:admin-widget widget-zone="product_...".../>` — copy-pasted from
-Admin without adapting it — and Store's `_ViewImports.cshtml` never added `@addTagHelper *,
-Grand.Web.Admin`, so that tag helper was already dead literal markup in Store's own pre-migration
-code (confirmed via `git show` on the pre-migration commit). Section 5.2's placeholder therefore
-preserved a genuine pre-existing bug rather than the intended behavior: `Grand.Web.Store` has its
-own `StoreWidgetViewComponent` (`Grand.Web.Store/Components/StoreWidget.cs`), registered as
-`vc:store-widget`, actively used elsewhere in Store's own views
-(`Areas/Store/Views/Home/Index.cshtml`, `Statistics.cshtml`, `Shared/_StoreLayout.cshtml`) with a
-`store_`-prefixed zone-name convention (`store_dashboard_top`, `store_header_before`, ...) — it was
-simply never wired into Product's widget zones, likely since the Store panel's Product screens were
-first added.
-
-### Resolution
-
-Same three-tier table as section 5.2, extended with Store's own row - Store gets the same treatment
-Vendor already has, using its own established `store_` prefix (mirrors `vendor_product_X`):
-
-| File | Content |
-|---|---|
-| `Grand.Web.Admin/Areas/Admin/Views/Product/Partials/WidgetZone.<Name>.cshtml` | `<vc:admin-widget widget-zone="product_X" .../>` (unchanged) |
-| `Grand.Web.Store/Areas/Store/Views/Product/Partials/WidgetZone.<Name>.cshtml` | **new:** `<vc:store-widget widget-zone="store_product_X" .../>` |
-| `Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/WidgetZone.<Name>.cshtml` | `<vc:vendor-widget widget-zone="vendor_product_X" .../>` (unchanged, 40 of 44 - Vendor has no Discounts/Documents tabs) |
-| `Grand.Web.AdminShared/Views/AdminShared/Product/Partials/WidgetZone.<Name>.cshtml` | empty placeholder (unchanged content, comment corrected - now genuinely unreachable except as the Discounts/Documents fallback for Vendor) |
-
-All 44 zones apply to Store (Store shows the same tabs as Admin; only Vendor's 4 gaps differ), so
-Store gets all 44, generated mechanically from Admin's 44 real files by substituting
-`vc:admin-widget` → `vc:store-widget` and prefixing each `widget-zone` value with `store_` - the
-same transform already proven correct by Vendor's `vendor_` prefix. New zone names
-(`store_product_...`) are brand new; no widget plugin currently targets them, so this changes no
-visible behavior today - it makes the extension point reachable for future (or existing,
-not-yet-Product-scoped) Store widget plugins, exactly like Vendor's equivalent zones were reachable
-but likely unpopulated when they were added.
-
-The three pre-existing Store-specific whole-file overrides kept outside AdminShared per section 4
-(`CreateOrUpdate.{Info,Prices,PurchasedWithOrders}.cshtml`, kept because each has a real grid/column
-difference from Admin) carried the same dead `vc:admin-widget` copy-paste and got the same fix in
-the same pass, since they're Store's own files either way.
-
-`Grand.Web.AdminShared.dll` keeps zero literal `<vc:` strings (unaffected - this section only adds
-real widget calls in `Grand.Web.Store`, never in AdminShared). `Grand.Web.Store.dll` gains real
-`StoreWidgetViewComponent` references in place of what would otherwise have been dead literal
-`<vc:store-widget>` markup, checked the same way section 5.2 checked Admin/Vendor.
-
-**Rule for Phase 3:** when checking "does host X have an equivalent mechanism" during a
-consolidation, check host X's *own* codebase for the real answer (does it have a widget component,
-is it used elsewhere, what does `_ViewImports.cshtml` actually import) - don't infer it from what
-the entity's *original*, pre-consolidation views for that host happened to contain. A copy-pasted,
-never-adapted call is evidence of a pre-existing bug, not evidence the host lacks the capability.
-
-## 8. Remove `IAdminDataScope<TEntity>.ApplyScope` (addendum, 2026-08-19)
-
-### Problem
-
-`ApplyScope(IQueryable<TEntity> query)` was part of the original Phase 1 interface design but never
-became load-bearing: `BaseProductController` and `ProductViewModelService` scope every read
-(`SearchProducts`) and write path through the `storeId`/`vendorId` parameters and `HasAccess`/
-`CanView` checks instead, never through an `IQueryable` filter. Confirmed by grep across `src/Web`
-and `src/Tests`: the only callers of `ApplyScope` were its own unit tests
-(`GlobalAdminDataScopeTests.ApplyScope_ReturnsQueryUnchanged`,
-`VendorProductDataScopeTests.ApplyScope_FiltersToOwnVendorId`) - dead production code advertising a
-scoping mechanism nothing uses, flagged during the tenant-isolation audit in section 6/7's session
-and removed on request rather than left to accumulate.
-
-### Resolution
-
-Removed the member from `IAdminDataScope<TEntity>` and its four implementations
-(`GlobalAdminDataScope<TEntity>`, `StoreAdminDataScope<TEntity>`, `VendorProductDataScope`,
-`RoutedProductDataScope`'s pass-through), plus the two tests that only existed to exercise it. No
-other code referenced it (grep clean after removal). `IStoreLinkEntity`/`Stores`/`LimitedToStores`
-filtering logic that lived inside `StoreAdminDataScope.ApplyScope` is not reproduced elsewhere - it
-was never called, so there is nothing to preserve.
-
-**If Phase 3 needs query-level scoping** (e.g. a list endpoint that filters via `IQueryable` instead
-of passing a `storeId`/`vendorId` parameter into a service method, the way Product does), add the
-member back on the entity/host where it is actually wired to a caller in the same change - not
-speculatively ahead of a caller, which is what happened here.
-
-### Verification
-
-`dotnet build GrandNode.sln` clean. `Grand.Web.Admin.Tests`/`Grand.Web.Store.Tests`/
-`Grand.Web.Vendor.Tests`: 419/33/8 (down 2 from the removed `ApplyScope` tests), all green.
-
-## 9. CodeQL: "missing CSRF token validation" on `BaseProductController.cs` (addendum, 2026-08-19)
-
-### Investigation
-
-CodeQL flagged `BaseProductController.cs`'s `[HttpPost]` actions as missing antiforgery validation.
-Checked: `BaseProductController` is `abstract` (never directly routable) and extends
-`Grand.Web.Common.Controllers.BaseController`, which carries no antiforgery attribute. Its three
-concrete subclasses (`Grand.Web.Admin`/`Grand.Web.Store`/`Grand.Web.Vendor`'s `ProductController`)
-each already declare `[AutoValidateAntiforgeryToken]` at the class level - restated there since Phase
-1 Task 11 explicitly because `BaseProductController` "can't inherit any single host's base controller"
-(each host's own `BaseAdminController`/`BaseStoreController`/`BaseVendorController`, which normally
-supplies it, differs by `[Area]`/`[Authorize*]`). ASP.NET Core resolves MVC filters from the full type
-hierarchy of the concrete controller at request time, so every actual runtime endpoint (there are only
-these three concrete subclasses - grep confirmed) is already protected. This is a static-analysis
-false positive in the sense that no exploitable gap exists today - CodeQL's query doesn't follow an
-attribute from a derived class in a different project back onto the base class where the actions are
-textually defined.
-
-### Fix
-
-Added `[AutoValidateAntiforgeryToken]` directly to `BaseProductController` too. This changes no
-runtime behavior (redundant with the three subclasses' own copies, and the base class was never
-routable anyway), but removes a real fragility the false-positive investigation surfaced: protection
-depended entirely on every current *and future* host subclass remembering to restate the attribute,
-with nothing enforcing it at the point where the actions actually live. Also gives CodeQL's static
-analysis something to see in the same file it flagged.
-
-### Verification
-
-`dotnet build GrandNode.sln` clean. `Grand.Web.Admin.Tests`/`Grand.Web.Store.Tests`/
-`Grand.Web.Vendor.Tests`: 419/33/8, unchanged, all green.