Developer forum

Forum » Ecommerce - Standard features » Primary Group and Multiple Shops

Primary Group and Multiple Shops

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

We have a solution where we have multiple shops for different countries. We also ha a PIM from where we publish products to one or more shops. In the shops the products could also belong to several groups, like "News" or some group for a campaign. 

The problem is that I of course would want a link to the products standard group in the current shop. In the eCom you can only set one primary group (obviously). 

I would need to have a primary group for each shop. How could this be achived? Any ideas?

Regards / Aki


Replies

 
Michael Knudsen
Reply

Hello Aki,

- since nobody have replied on you topic, am I curious if you have found a solution yourself?

Or have Dynamicweb a solution for this in 2022?

Br. Michael Knudsen

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Michael,

From what I know, the recent versions of DW will always return the PrimaryOrDefault group depending on the current shop context.

Meaning that you should not get a Warehouse GroupID while you are in an ECOM context. However, you cannot control the default group by Shop. You can always have one default shop per product.

Adrian

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

At the moment we don't have a solution for it. 

Regards / Aki

 
Aki Ruuskanen
Aki Ruuskanen
Reply

But the canonical link is correct so it's OK for now. 

Regards / Aki

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We are very much missing this feature to have a primary group for each shop.

 

Best regards, Anders

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Primary can only be there once - and we cannot change that concept because it controls inheritance and all kind of other things. Primary was introduced to ensure a product has exactly and only one primary.

What is the actual problem that needs to be solved? Is it a matter of choosing the preferred canonical URL for products with multiple group relations in the same shop? Or is it to only have one URL in a given shop context? The latter would mean that navigation Products/Sales/someProduct would give you the URL products/men-shirts/someProduct and go away from the navigation context. Or do you want to keep the navigation context (so both URLs will exist, but using a canonical).

 
Aki Ruuskanen
Aki Ruuskanen
Reply

In our case the actual problem is that a products primary group URL is for example:  shop.se/products/productgroup/subgroup/product-A

And then we have a some productlistnings with featured products on the startpage where wi display product from productgroup called "Startpage" and those products gets the URL shop.se/start/product-A instead of the "real" URL. 

The PrimaryGroup feature would solve that if the product only existed in one shop, but it exists in five shops. 

Regards / Aki

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Aki

Yes - but that problem you mention here, comes not from the missing primary setting, but from a "malformed" link to the product on the frontpage.

When rendering the list of products, you have to create a link that contains the "PrimaryOrDefault" group from the product - which takes the current shop context into consideration. That will then return a group from the current shop. On that group, you can specify the default page for the group (and that can be different on different languages). Using that group and the pageid from that group instance, you can create a URL like this /Default.aspx?ID={GroupPrimaryPageID}&GroupID={Product.PrimaryOrDefaultGroupID}&ProductID={ProductID}.

The productViewmodel has a property, PrimaryOrDefaultGroup, that will give you the correct groupid. Also there is an extention method for ProductViewmodel in Dynamicweb.Ecommerce.Productcatalog namespace that will give you a GetProductLink() method that will generate the above URL for you (you need a relatively late DW 9.14 to get that extension method)

With what you describe, it sounds like you just do "Default.aspx?ID={CurrentPageID}&ProductID={ProductID}.

Also it indicates that you are still on the 'old' URL system and not the page based URL providers that are more 'precise' and can be controlled better.

For reference - this is how the above extension method is creating the link - if you need to re-create it on older installations:

 public static string GetProductLink(this ProductViewModel product, int pageId, bool usePrimaryGroupPageId = true)
        {
            if (product.PrimaryOrDefaultGroup.PrimaryPageId > 0 && usePrimaryGroupPageId)
                pageId = product.PrimaryOrDefaultGroup.PrimaryPageId;

            var productlink = $"Default.aspx?ID={pageId}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}";

            if (!string.IsNullOrEmpty(product.VariantId))
                productlink += $"&VariantID={product.VariantId}";

            return productlink;
        }

If you are still on the tag based product catalog, it also contains a tag for this.

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

Thanks for that input, Nicolai. I will look into it. Sounds like it will solve that problem. :) 

At the moment, I'm off to a short christmas leave and will have a beer or two. 

Merry Christmas!

Regards / Aki

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Sounds like the best idea.

Enjoy the holidays and merry x-mas

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Nicolai,

 

What we need to achive is to have a preferred canonical URL for products with multiple group relations in the same shop for SEO purpose (yes, I know... :-) ). How can this be done?

 

Best regards, Anders

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

It's a useful feature request and at the same time a very complicated one.

Probably a "Canonical-specific" setting would do the trick. Either on the Group relations screen (use as canonical for shop X)

or maybe a dedicated section in the Meta area on the product detail.

 

The challenge here is the management of the setting in situations where products are assigned to a lot of groups that are not relevant for the canonical URL.

Maybe it would make sense to decide which groups are suitable to be used for canonical URL. But even then, you can have a product assigned to 2 canonical groups in the same shop and you also need an option to make a decision at product level.

A lot of possible scenarios of usage :)

Adrian

 

You must be logged in to post in the forum