Copied to clipboard

Flag this post as spam?

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


  • Niclas Schumacher 6 posts 77 karma points
    Apr 08, 2016 @ 20:48
    Niclas Schumacher
    1

    Product variants URL

    Hey ! I've been fumbling around with Merchello creating a product page, which most of the time has gone pretty well.

    I just can't seem to figure out how i can get an URL for my variants, if it is even possible, or should i have skuIds in the URL on the product page instead?

    In fact, what i want is not being able to buy my product, but only my variants, so depending on the options choosen the page should change (async) with the other variants images.

    But the only way i've been able to have a url page is to have query parameters for the options in an array, and then check if i can get an variant by calling the GetProductVariantWithAttributes with the options.

    Let me explain with some code, how ive done it now, but there must be a better way.

    var productContent = CurrentPage as IProductContent;
           //Get a IProduct, because GetProductVariantWithAttributes only takes a IProduct as parameter
            var product = productService.GetByKey(productContent.Key);
    
    // Get the choosenVariant, if any, based on options Guids.
            var choosenVariant = productvariantService.GetProductVariantWithAttributes(product, options);
    
            //get the IProductVariantContent, because the is the only that has content properties, like images, description etc.
            var variant = product.ProductVariants.First(x => x.Key == productVariant.Key);
    

    Does it make sense what im trying to do ?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies