Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Lee 1130 posts 3088 karma points
    Mar 05, 2014 @ 10:34
    Lee
    0

    Related Products With Multiple Stores?

    We are using the build in Product.GetRelatedProducts() method to get related products, however we are using a multi-store implementation.

    And the product has related products from two different stores, both related products are not enabled/available in the other store.

    But using this method, just gets all related products. Irrelevant of whether they are available in the store or not? Have a missed something? I would have thought it would check to see if the product is actually allowed to be in the store before adding it?

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Mar 05, 2014 @ 10:54
    Nickolaj Lundgreen
    0

    I guess it's made that way incase you need to do some sort of cross-store related products. You should however be able to make an extension yourself, that removes the product not present in the current store.

    I might be a little tricky to get the info, but im thinking something like:

    Get all catalogs from the present store
    Get all categories from the catalogs.
    
    Check if the product is present in any of categories.
    

    Not sure if there is an easier way?

  • Martin 181 posts 740 karma points
    Mar 07, 2014 @ 18:55
    Martin
    0

    Hi Lee,

    A solution might be:

    ProductProductRelations
    .Where(
    pr => pr.ProductRelationType.Name == "relationName" &&
    pr.RelatedProduct.CategoryProductRelations.Any(pcr => pcr.Category.ProductCatalog == SiteContext.Current.CatalogContext.CurrentCatalog));

    I have not tested the code but it should be working as intended. Depending on how much data you have the query should perhaps be optimized.

    Best regards Martin

    Edit: It should compile now with following namespaces

    using UCommerce.EntitiesV2;
    using UCommerce.Runtime;

Please Sign in or register to post replies

Write your reply to:

Draft