logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
judy at Web2Market  
#1 Posted : Tuesday, December 29, 2020 10:51:35 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 286

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



Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyartiwana25816656  
#2 Posted : Monday, January 4, 2021 1:03:26 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 703

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.
judy at Web2Market  
#3 Posted : Monday, January 4, 2021 6:40:23 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 286

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.
judy at Web2Market  
#4 Posted : Tuesday, January 5, 2021 7:51:32 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 286

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

shaharyartiwana25816656  
#5 Posted : Wednesday, January 6, 2021 6:00:57 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 703

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?
judy at Web2Market  
#6 Posted : Wednesday, January 6, 2021 6:44:30 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 286

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
judy at Web2Market  
#7 Posted : Wednesday, January 6, 2021 7:41:50 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 286

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).
Users browsing this topic
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.