private void CreateShippingMethod(string name, decimal shippingFee, Currency currency, PriceGroup priceGroup) { var shippingMethod = ShippingMethod.SingleOrDefault(x => x.Name == name) ?? new ShippingMethodFactory().NewWithDefaults(name); var shippingMethodPrice = shippingMethod.ShippingMethodPrices.FirstOrDefault(p => p.PriceGroup.Currency.ISOCode == currency.ISOCode); if (shippingMethodPrice == null) { shippingMethodPrice = new ShippingMethodPrice() { PriceGroup = priceGroup }; shippingMethod.AddShippingMethodPrice(shippingMethodPrice); } shippingMethodPrice.Price = shippingFee; shippingMethodPrice.PriceGroup = priceGroup; shippingMethodPrice.Save(); shippingMethod.ClearEligibleCountries(); foreach (var country in _countries) { shippingMethod.AddEligibleCountry(country); } shippingMethod.ClearEligibilePaymentMethods(); foreach (var method in _paymentMethods) { shippingMethod.AddEligiblePaymentMethod(method); } shippingMethod.Save(); }