Copied to clipboard

Flag this post as spam?

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


  • Nguyen Dung Tri 106 posts 606 karma points
    Sep 19, 2016 @ 04:15
    Nguyen Dung Tri
    0

    How to add a category for exist product?

    Hello,

    I want to add a category for exist product. How can I do that from the code behide?

    This is an example code:

    public ProductDisplay AddProduct(ProductDisplay product)
    {
        var merchProduct = _productService.CreateProduct(product.Name, product.Sku, product.Price);
    
        merchProduct.Category = "New Category" ///This line is to set a new category for product.
    
        merchProduct = product.ToProduct(merchProduct);
        _productService.Save(merchProduct);
        return merchProduct.ToProductDisplay(DetachedValuesConversionType.Editor);
    }
    

    After add a new category the category should show in product box:

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft