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.

Migrate TierPriceCreatePopup to AdminShared, pilot for view consolidation (ARCH-001 Phase 2)

KrzysztofPajak2fc0868b93b5
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
index e53f0eeac..d6d7e9353 100644
--- 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
@@ -147,6 +147,82 @@ 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
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml b/src/Web/Grand.Web.AdminShared/Views/Product/TierPriceCreatePopup.cshtml
similarity index 82%
rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml
rename to src/Web/Grand.Web.AdminShared/Views/Product/TierPriceCreatePopup.cshtml
index 33a330258..0a022e837 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/TierPriceCreatePopup.cshtml
+++ b/src/Web/Grand.Web.AdminShared/Views/Product/TierPriceCreatePopup.cshtml
@@ -1,13 +1,14 @@
-@model ProductModel.TierPriceModel
+@model ProductModel.TierPriceModel
@{
Layout = "";
//page title
- ViewBag.Title = Loc["Admin.Catalog.Products.TierPrices.AddNew"];
+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.TierPrices.AddNew"];
+ var area = ViewContext.RouteData.Values["area"]?.ToString();
}
-<form id="TierPriceCreatePopup" asp-area="@Constants.AreaAdmin" asp-controller="Product" asp-action="TierPriceCreatePopup"
+<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"])">
@@ -18,7 +19,7 @@
<div class="x_title">
<div class="caption">
<i class="fa fa-cube"></i>
- @Loc["Admin.Catalog.Products.TierPrices.AddNew"]
+ @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.TierPrices.AddNew"]
</div>
</div>
<div class="x_content form">
@@ -58,4 +59,4 @@
});
});
</script>
-</form>
\ No newline at end of file
+</form>
diff --git a/src/Web/Grand.Web.AdminShared/Views/_ViewImports.cshtml b/src/Web/Grand.Web.AdminShared/Views/_ViewImports.cshtml
new file mode 100644
index 000000000..ffa2936d5
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Views/_ViewImports.cshtml
@@ -0,0 +1,21 @@
+@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
diff --git a/src/Web/Grand.Web.AdminShared/Views/_ViewStart.cshtml b/src/Web/Grand.Web.AdminShared/Views/_ViewStart.cshtml
new file mode 100644
index 000000000..7447c721b
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Views/_ViewStart.cshtml
@@ -0,0 +1,5 @@
+@using Microsoft.AspNetCore.Routing
+@{
+ var area = Context.GetRouteValue("area")?.ToString();
+ Layout = $"~/Areas/{area}/Views/Shared/_{area}Layout.cshtml";
+}
diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml
deleted file mode 100644
index f56e53cdc..000000000
--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Product/TierPriceCreatePopup.cshtml
+++ /dev/null
@@ -1,61 +0,0 @@
-@model ProductModel.TierPriceModel
-
-@{
- Layout = "";
-
- //page title
- ViewBag.Title = Loc["Admin.Catalog.Products.TierPrices.AddNew"];
-}
-
-<form id="TierPriceCreatePopup" asp-area="@Constants.AreaStore" 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["Admin.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>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml
deleted file mode 100644
index 5d87d3aac..000000000
--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/TierPriceCreatePopup.cshtml
+++ /dev/null
@@ -1,61 +0,0 @@
-@model ProductModel.TierPriceModel
-
-@{
- Layout = "";
-
- //page title
- ViewBag.Title = Loc["Vendor.Catalog.Products.TierPrices.AddNew"];
-}
-
-<form id="TierPriceCreatePopup" asp-area="@Constants.AreaVendor" 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["Vendor.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>
\ No newline at end of file