Developer forum

Forum » Ecommerce - Standard features » Custom eCom URL Provider

Custom eCom URL Provider

Mikkel Toustrup Olsen
Reply

Hello,

I am currently working on a project where we're using the "new" Ecom URL Provider that takes an alternateUrlKey - a given language code -  as the 4th parameter (see ssForForum). 

In my Ecom URl Provider I am parsing my languages (hardcoded)  - see attached ssForForum2 - to the Mapping instances in my list which I later return. I have debugged it, and my list contains all of my productids for each country which is my goal.

However, when trying to getthe Ecom Url Provider to actually use the chosen country something goes wrong. According to DW I am to set the "alternateUrlKey" to the respective language as early in the process. I am doing that in my ApplicationBeginRequestObserver.cs.  (see attached ssForForum3) . The method HCBase.Util.GetCurrentLanguageCode()  returns a session variable containing the chosen country  - if e.g. Germany - "de" is Parsed to this Session. However this happens on a PageGlobalTagsNotificationSubscriber as I dont have access to the Pageview before this.

So basically, the binding from the Session (or chosen country) to the Ecom URL Provider is somewhat missing.

In other words I cannot seem to trigger the alternateUrlKey.

BR

MikkelTO

ssForForum.png ssForForum2.png ssForForum3.png

Replies

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Yes, that will not work.

But you should be able to find the session in the notification subscriber - using app.Context.Session. But you need to read the value directly and remember that many times session will not exist (i.e. when bots are indexing).

And i wrote that in the mail when I gave it to you. It is a big problem that the URLs are depending on a session. URLs is the first thing to be resolved. It is called a "Unified Ressource Locator" meaning it is used to find the right content. You want to find the right content, and based on that have the right URL - something is wrong with that... A search engine does not have sessions either.

So this is the hen and the egg problem.

You cannot use the pageview instance to fnd the URL - because the URL is used to find the pageview... Makes sense?

BR Nicolai

 
Mikkel Toustrup Olsen
Reply

Hey Nicolai,

Thanks for your quick reply :-)

Yeah it does make sense. If I set the languageKey to e.g. NL in the OnApplicationBeginRequestObserver, will I then be ablle to parse DE to this when changing country? and will the Ecom Provider automatically change this if my complete list, which only runs 1 time, contains the given product id and of course the given alternateUrlKey .

/MTO

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Not sure I fully understand... In the URL provider you load all combinations of alternatekey, URL and product ID. That happens only once When the observer runs, you tell what should be used as the alternate key. That happens on every pageview...

The flow is like this:

On appliation load: The entire URL index is built.

On each request: URL is parsed from /Page/Groupname/ProductName to ?ID=1&GroupID=23&ProductID=45 - that happens only once also.

The alternate key decides what part of the URL index should be used when resolving ProductName to &ProductID=45. And you have ProductName, ProductNameEN, ProductNameDE etc. and you need to know when which is used.

BR Nicolai

 
Mikkel Toustrup Olsen
Reply

Hi Nicolai,

Yeah basically I have my URL Provider which contains all of the possible combinations given on the parsed alternateUrlKey. DA-ProdID1, DE-ProdID1, NL-ProdID1 and so on.

In my Observer I then set the app.context.Session["alternateUrlKey] = whatEverLangCodeIWantToParse, right? - And then let the Provider return the correct URL.

BR

Mikkel

 
Nicolai Høeg Pedersen
Reply

You should set app.context.Items["alternateUrlKey] = whatEverLangCodeIWantToParse. But you might get it from app.context.Session["alternateUrlKeyFromUserSession]

 
Mikkel Toustrup Olsen
Reply

Then I must admit I quite don't understand where you set the Session variable in that case :) - might be me who's missing something

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

You would have it set when the user changes language the first time. Then on subsequent visits you can use that.

But I understand why you are confused, because what you are doing does not make much sense to me....

You have 2 URLs that resolves to the exact same page and product.

/ProductPage/DanishProductName.aspx resolves to ?ID=1&ProductID=2.
Because no session is set, you know when you show the product, that you should not translate the product name. On the notification subscriber you can see that there is no session, so you DO NOT set app.context.Items["alternateUrlKey] to anything. DW will fallback to default key. Or you set the app.context.Items["alternateUrlKey] to the string "DA" or whatever.

Now the user changes language by clicking a link or something. I.e. ?ID=1&Product=2&changeToLanguage=EN. When that happens, you record the new language on the session and you have to do a redirect, maybe just to the same URL but without the changeToLanguage parameter. Now in your notification subcriber you can see that a session is available, and you set app.context.Items["alternateUrlKey] to the value in the session ("EN"). When you render the product, you can see that session as well and change the product name....

When the user clicks in the navigation, it should also be resolved to the right URL automatically. So no need to do stuff in that one.

 
Mikkel Toustrup Olsen
Reply

Hi Nicolai,

It does not seem to trigger at all, unfortunately.

However, I think we've come to the conclusion that we setup the different Ecom languages and do some SQL magic after the initial product import that copies the products to their respective ecom countries and then utilize the standard dynamicweb ecom url provider stuff. 

BR

Mikkel

 

You must be logged in to post in the forum