London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Setting tax category for an variant/sku programatically

Vote:
 

I'm building a scheduled job which which creates variants/skus and I'm not sure how to set the tax category for each variant/sku.

Code as follows:

CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(myEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

            if (entryDto.CatalogEntry.Count > 0)
            {
                CatalogEntryDto.VariationRow[] variationRows = entryDto.CatalogEntry[0].GetVariationRows();

                if (variationRows.Length > 0)
                {                                                                                                
                    CatalogTaxDto categories = CatalogTaxManager.GetTaxCategories();

                    if (categories.TaxCategory.Count > 0)
                    {                       
                        variationRows[0].TaxCategoryId = categories.TaxCategory[0].TaxCategoryId;
                    }                  
                }
            }

It goes through the code and sets the taxcategoryid, but it is not set when I go to that specific variant in Catalogue view. Do I need to save it somehow or set something more than the id? The documentation I find is for getting the values, not for setting, so something is missing here.

Help appreciated.

/J

#118566
Mar 10, 2015 11:01
Vote:
 

Hi,

You need to call CatalogContext.Current.SaveCatalogEntry(catalogEntryDto) to save the changes.

Regards.

/Q

#118573
Mar 10, 2015 11:57
Vote:
 

Great thanks Quan!

#118588
Mar 10, 2015 15:56
Vote:
 

Hi,

How do you set tax category  on packages? 


regards

Pawel

#185109
Nov 09, 2017 15:13
Vote:
 

We suggest to use the new content APIs, and PackageContent implements IPricing, which has TaxCategoryId property that you can set. 

#185248
Nov 13, 2017 15:24
Vote:
 

Thanks!  will try it out! 

#185254
Nov 13, 2017 16:21
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.