AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Creating new page that needs productId passed to it
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I have to create a page that requires the productId passed from a link on the product page. I've added code to the ProductController and created a view for that page which displays that product and some of the product accessories. http://localhost/Able9B6432Test1/ProductBundle/5775 I added an entry to the RouteConfig file: routes.MapRoute( name: "ProductBundle", url: "ProductBundle/{id}", defaults: new { controller = "Product", action = "BuyProductBundle", id = UrlParameter.Optional }, namespaces: new[] { "AbleCommerce.Controllers" } ); I can get the page to pull up the data, but haven't been able to get it to pick up store header, styles, etc. If I try to add Layout = "~/Views/Shared/_Base.layout.cshtml"; I get an null reference error in the _CMSIncludes.cshtml at string theme = CurrentRequestData.PageData.Theme;
I tried putting the theme name into the ProductBunlde.chstml PageData["Theme"]="actualthemename"; but that didn't work.
I also tried added an ApplicationPage using various outer templates or a new outer template and a new inner template, but get various errors, depending on if I pass the productid in the url or not. What is the best way to do this? I need to add other custom pages that have productIds passed to them also. Thanks
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Hi Judy,
In AC9, everything on the retail side is a widget or an HTML snippet. To meet your requirements I would suggest the following:
1- Add [RegisterWidget] attribute to the action method you created in ProductController. This will register this as a widget and you should be able to see this in the widget list. (See ProductName action method in ProductController as an example) 2- Create a new content page from the admin side and set the URL as /ProductBundle 3- Create an inner template and also name it ProductBundle (to be specific). From the layout tab, add 12 size columns and add a zone. From the content tab, drag and drop the new widget from the General category
Note: No need to add an entry in RouteConfig, set Layout in view file, and set the theme value.
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Thanks, I will try that. I think I did try it, but couldn't add content to the content page. I know I didn't know to add 12 size columns and a zone.
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I have done this, but am getting errors when I try to pass the productId to the page. I've tried /ProductBundle/5775 and I get a 404 error I've tried /ProductBundle?ProductId=5775 and get redirected to the normal product page How can I pass the productId? Thanks Edit: Do I need to put anything in the Html tab of the Content page? Edited by user Tuesday, January 5, 2021 7:53:42 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Quote:I've tried /ProductBundle?ProductId=5775 and get redirected to the normal product page It should not redirect to product page just because of the id in querystring. Is there any other widget on this page that might be reedirecting because of some logic? Please debug and confirm that the request is being received by your ProductBundle action method?
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I debugged and it was going to BuyProductDialog, but I don't know why. I changed the widget category from Product to General and re-did the inner template and the content page in the admin and now it work! I don't know which change fixed it. Thanks
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
One new problem. I have two submit buttons on the page and the controller routes the action depending on which button. The add to basket routine works. The other routine showSavings goes through the code OK and populates three ViewBag variables, then when the page post back to itself, the values are displayed. This used to work before I put it into a content page. I can debug the view and I see that the ViewBag values are picked up OK. They just don't show on the page anymore. Any ideas? Thanks 2021-01-06_8-32-05.png (14kb) downloaded 0 time(s).
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Creating new page that needs productId passed to it
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