Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
I'm studying how you guys render product variant choices on the product page. I notice in the _ProductQuickView view that you have a single reference to BuyProductDialog: Code:@Html.Action("BuyProductDialog", new { ProductId = Model })
My first question: Is that all I really need if I want to render the variant dropdowns for a given product id? I need to build a page that offers the variant choices for a product so I can add-to-cart based on the shopper choices. I'm not complaining at how easy it looks. I'm more worried my inexperience with this area of the code is making it look easier than it really is. It just looks really easy lol My second question: The BuyProductDialog methods in the ProductController class don't have an overload with just a ProductId as the parameter. When I hit F12 on the action name, I get two choices both of which involve BuyProductDialogParams but not 'ProductId'. So how does MVC know which action method to call since neither one has a parameter for ProductId? I thought actions could only call a method with a matching signature? Shouldn't there be a public BuyProductDialog(int ProductId) somewhere in the controller??
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
BuyProductDialogParams is found in /Models/ProductModels.cs. It includes a property for the ProductId, so I'm pretty sure it is being bound to that. It also has a property for ShowAllOptions that defaults to false. I may be mistaken, but you may be able to set that property to true to get the behavior you are looking for.
|
|
|
|
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
Originally Posted by: sweeperq1766875 BuyProductDialogParams is found in /Models/ProductModels.cs. It includes a property for the ProductId, so I'm pretty sure it is being bound to that. It also has a property for ShowAllOptions that defaults to false. I may be mistaken, but you may be able to set that property to true to get the behavior you are looking for. Ok thanks. So that answers Q2. So when I call an Action method, I don't necessarily have to specify the exact method signature. As long as a signature includes a property matching the parameters that I did supply, MVC will wire it up for me. Good to know, I didn't realize that. Hey I just learned yesterday you can pass custom properties as ViewBag data when calling @Html.Partial() - cool stuff!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close