Developer forum

Forum » PIM » Setting the primary page ID for a PIM feed

Setting the primary page ID for a PIM feed

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a PIM feed that should generate links to products. When I preview the feed, the links end up as https://domain.dk/default.aspx?ID=0&ProductId=1032860

Because of the ID being zero, the links return a 404

How do I set this ID? When I look inside XMLProvider, I see this:

var shop = Services.Shops.GetShop(feedContextConfiguration.ShopId);
if (shop is object)
{
    xsltArguments.AddParam("product-catalog-page-id", "", shop.ProductPrimaryPageId);
}

 

However, I can't seem to set ProductPrimaryPageId on the shop, other than in the database directly. Am I missing something?

Imar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

You can on the warehouse: 

 
Michael Knudsen
Reply

But thats only available on a PIM warehouse.

Br. Michael Knudsen

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> But thats only available on a PIM warehouse.

Exacly. I need it for a specific shop. I have one PIM warehouse that feeds products into multiple shops so I need an ID per shop in order to link to the correct product details page.

Imar

 
Søren Jensen Dynamicweb Employee
Søren Jensen
Reply

Hi,

Woulden it be possible to define a CategoryField per Shop, using FieldTypeProvider "Concat", where you can build the URL with correct ID's ..

Then it automatically will generate the URL per Shop & Product ..

Then extract these Field's in the Feed ..

/Søren

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

That sounds like a really complicated way. Wouldn't a product detail page link on the feed UI or shop make a lot more sense?

If I go your route, where would the link be picked up by the feed bullder? The XSLT seems to go against the primary page ID parameter which is filled with the shop's primary page ID so not sure how it would magically pick up the new field.

Imar

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Different products can have different detail pages.

The product viewmodel do have a PrimaryOrDefaultGroup which is a GroupInfoViewmodel with a PrimaryPageID property. That will get the pageid from group settings supporting multiple detail pages.

But you are asking to get the default page id on shop edit I guess?

BR Nicolai

 

 
Michael Knudsen
Reply

Hello Imar,

- normally I use XSLT and hardcore the primary page id in the XSLT template + using a msxsl:script to get a 'friendly url' from Dynamicweb:

<xsl:variable name="product-catalog-page-id" select="'6875'" />
<msxsl:script language="C#" implements-prefix="co3">
<msxsl:assembly name="netstandard"/>
<msxsl:assembly name="Dynamicweb"/>
<![CDATA[  
public string friendlyUrl(string url)
{
url = url.Replace("&amp;", "&");
string urlStr = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(url);
return urlStr;
}
     ]]>  
</msxsl:script> 

Please let me know by mail, if you want a full XSLT example.

Br. Michael Knudsen

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Michael,

Yes please that would be great. I tried your code but get a "Prefix 'co3' is not defined." so I think I miss some declaration for it somewhere.

Thanks!

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> But you are asking to get the default page id on shop edit I guess?

Yes, I think so. Or some other way to set it (like a page picker directly on the feed provider) so I can point to a single PDP for the entire feed.

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks for sending me the XSLT file. What I was missing was this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                xmlns:co3="urn:co3-scripts" 
                version="1.0" exclude-result-prefixes="msxsl co3">
 
The links now includes the page ID which is nice. The friendly URL doesn't quite work though. It renders something like this:
 
/tekstiler/produktside?ProductID=1025629
 
where I was expecting it to include the product name:
 
/tekstiler/koekken/nohr-viskestykke-50x80-cm
which is the canonical for the product page when I browse to it directly.
 
So it seems it's making the page structure friendly but not the ecom part. 
 
The ecom product has a primary group assigned.
 
Imar
 
 
Michael Knudsen
Reply

Hello Imar,

- are you using the producturl template?  If yes, please send me the XSLT file, so I can take a closer look at the missing part, since it's working for me.

<xsl:template name="producturl">
<xsl:element name="ProductUrl">
<xsl:if test="VariantId != ''">
<xsl:variable name="varianturl" select="concat('default.aspx?ID=',$product-catalog-page-id,'&amp;ProductId=', Id, '&amp;VariantId=', VariantId)" />
<xsl:value-of select="concat($domain-name, co3:friendlyUrl($varianturl))" />
</xsl:if>
<xsl:if test="VariantId = ''">
<xsl:variable name="producturl" select="concat('default.aspx?ID=',$product-catalog-page-id,'&amp;ProductId=', Id)" />
<xsl:value-of select="concat($domain-name, co3:friendlyUrl($producturl))" />
</xsl:if>
</xsl:element>
</xsl:template>

Br. Michael Knudsen

 

You must be logged in to post in the forum