Developer forum

Forum » Rapido » Related product feed using GroupId

Related product feed using GroupId

Søren Bremholm Jakobsen
Reply

Hi, I'm working on a task with related products. What I want to achieve is it no related products are set up for a given product then all products in the same product group should be displayed as related products. I have change the related products code in the product template to add GroupId to the feed url if nothing found in the related product loop. The first 4 products returned from the feed are correct but when using next button on the productpage the feed returns all products and not products in the group. The repository query contains a parameter for groupid – any suggestions?

if (GetLoop("ProductRelatedGroups").Count > 0)
    {
        foreach (LoopItem relatedGroup in GetLoop("ProductRelatedGroups"))
        {
            string relatedGroupId = ToPascalCase(relatedGroup.GetString("Ecom:Product:RelatedGroup.Name"));
            string relatedFeed = feedFullUrl + "&" + relatedGroupId + "=" + productId + "&GroupName=" + relatedGroupId;

            ProductSection relatedSectionObject = new ProductSection();
            relatedSectionObject.name = relatedGroup.GetString("Ecom:Product:RelatedGroup.Name");
            relatedSectionObject.id = relatedGroupId;
            if (relatedProductsLayout != "top")
            {
                relatedSectionObject.helper = @RelatedProducts(relatedSectionObject.name, relatedGroupId, relatedFeed);
            }
            else
            {
                relatedSectionObject.helper = @RelatedProductsMini(relatedSectionObject.name, relatedGroupId, relatedFeed);
            }
            relatedSectionObject.layoutType = relatedProductsLayout;
            productSectionsList.Add(relatedSectionObject);
        }
    }
    else
    {
        //activity = GetString("Ecom:Product:Field.Activity");
        string relatedGroupId = ToPascalCase(HttpContext.Current.Request.QueryString.Get("GroupID"));
        string relatedId = relatedGroupId.ToUpper();
        string relatedFeed = feedFullUrl + "&" + relatedGroupId + "=" + productId + "&GroupID=" + relatedId;

        ProductSection relatedSectionObject = new ProductSection();
        relatedSectionObject.name = Translate("Related product by activity");
        relatedSectionObject.id = relatedGroupId;
        if (relatedProductsLayout != "top")
        {
            relatedSectionObject.helper = @RelatedProductsGroup(relatedSectionObject.name, relatedId, relatedFeed);
        }
        else
        {
            relatedSectionObject.helper = @RelatedProductsGroupMini(relatedSectionObject.name, relatedGroupId, relatedFeed);
        }
        relatedSectionObject.layoutType = relatedProductsLayout;
        productSectionsList.Add(relatedSectionObject);
    }


Replies

 
Nicolai Pedersen
Reply

When you click the next button - is the groupid applied to that url? Have a look in developer tools network section to see if it is there. It sounds like that could be missing.

BR Nicolai

 
Søren Bremholm Jakobsen
Reply

the Url on the next looks like this /Default.aspx?ID=1320&GroupID=GROUP120&PageNum=2&PageSize=4&ProdID=3-88200&feed=true&Group120=3-88200 and the next 4 products returned is from group 122. The feed url returns all products

 

 
Nicolai Pedersen
Reply

And how does the initial url look like - the one that loads the first 4 products that are ok?

 
Søren Bremholm Jakobsen
Reply

data-json-feed="/Default.aspx?ID=1320&GroupID=&PageNum=1&GroupID=GROUP120&PageSize=4&ProdID=3-88200&feed=true&Group120=3-88200"

 
Nicolai Pedersen
Reply

Hi Søren

The 2 urls you have posted seems to be from your markup - I would like to see how the look in your developer tools network tab - as I can see exactly what is send to server.

There are 2 things that you should look into. Your urls have both url encoded &-signs - and non-url encoded (and I think this is the issue). If your urls are from the network tab, this is definitley the problem.

Default.aspx?ID=1320&GroupID=GROUP120&PageNum=2&PageSize=4&ProdID=3-88200&feed=true&Group120=3-88200

Also - the first page url contains the GroupID querystring twice - and the other does not:

Default.aspx?ID=1320&GroupID=&PageNum=1&GroupID=GROUP120&PageSize=4&ProdID=3-88200&feed=true&Group120=3-88200

 

You must be logged in to post in the forum