Developer forum

Forum » Ecommerce - Standard features » Product canonical meta tag

Product canonical meta tag

Umar Farooq
Reply

Hi,

On the Product detail page there is a canonical meta tag with link (href) so i would like to know how this url is generated at first place?

Is it possible to get this canonical meta tag URL?

I tried following but it give nothing

Product test = Product.GetProductByID(i.GetString("Ecom:Product.ID"));

@test.Meta.URL

 

Best Regards,

Umar


Replies

 
Nicolai Høeg Pedersen
Reply

The URL is either generated automatically on render or is coming from the canonical input in the product meta data.

It is not possible to get that information. For what do you need it? There might be a better option.

Attached the code that generates the canonical:

If Not String.IsNullOrEmpty(Product.Meta.Canonical) Then
                        AddCanonical(Product.Meta.Canonical)
                    ElseIf Product.Groups IsNot Nothing AndAlso Product.Groups.Count > 0 Then
 
                        'First, find right group
                        Dim canonical As String = String.Empty
                        If Not String.IsNullOrEmpty(Product.PrimaryGroupID) Then
                            If Product.PrimaryGroupID <> Base.Request("GroupID") Then
                                canonical = EnsureGroupCanonical(FixedPathAndQuery(), Product.PrimaryGroupID)
                            End If
                        End If
 
                        'Then Check if group is on right page
                        If Not primaryGroup Is Nothing AndAlso primaryGroup.Meta.PrimaryPageID > 0 AndAlso primaryGroup.Meta.PrimaryPageID <> Me.PageView.ID Then
                            If String.IsNullOrEmpty(canonical) Then
                                canonical = FixedPathAndQuery()
                            End If
                            canonical = EnsureGroupPageCanonical(canonical, primaryGroup)
                        End If
 
                        'Remove variant from canonical url
                        If Not String.IsNullOrEmpty(Base.Request("VariantID")) Then
                            If String.IsNullOrEmpty(canonical) Then
                                canonical = FixedPathAndQuery()
                            End If
                            canonical = RemoveVariantCanonical(canonical, Product.DefaultVariantComboID)
                        End If
 
                        If Not String.IsNullOrEmpty(canonical) Then
                            canonical = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(canonical.Trim("/"c))
                            'Base.w(canonical)
                            AddCanonical(canonical)
                        End If
                    End If
 
Umar Farooq
Reply

Hi Nicolai,

Thanks for your response, Apparently on one of our solutions we have page's in a tree with ecom products and we are also using a instant search function. So when you search for a product and click on a product link in search it lands on another page instead of category specific page. So i was thinking to use these meta data url which we already have to create a custome link instead of doing custom codding in search functionality which could give a slow performance ? Can you give any better suggetions on how to handle this issue??

 

Best Regards,

umar

 
Nicolai Høeg Pedersen
Reply

You could make a 'normal' and 'simple' ecommerce implementation... :-).

On a group you can specify its primary page, that will change the link to the product - see meta section in the manual:

http://manual.dynamicweb-cms.com/Dynamicweb-eCommerce/Product-groups/How-to-create-a-new-product-group.aspx

BR Nicolai

 

You must be logged in to post in the forum