本文整理汇总了C#中Nop.Core.Domain.Catalog.ProductVariant.GetLocalized方法的典型用法代码示例。如果您正苦于以下问题:C# ProductVariant.GetLocalized方法的具体用法?C# ProductVariant.GetLocalized怎么用?C# ProductVariant.GetLocalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Catalog.ProductVariant
的用法示例。
在下文中一共展示了ProductVariant.GetLocalized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyProductVariant
//.........这里部分代码省略.........
OrderMaximumQuantity = productVariant.OrderMaximumQuantity,
AllowedQuantities = productVariant.AllowedQuantities,
DisableBuyButton = productVariant.DisableBuyButton,
DisableWishlistButton = productVariant.DisableWishlistButton,
CallForPrice = productVariant.CallForPrice,
Price = productVariant.Price,
OldPrice = productVariant.OldPrice,
ProductCost = productVariant.ProductCost,
SpecialPrice = productVariant.SpecialPrice,
SpecialPriceStartDateTimeUtc = productVariant.SpecialPriceStartDateTimeUtc,
SpecialPriceEndDateTimeUtc = productVariant.SpecialPriceEndDateTimeUtc,
CustomerEntersPrice = productVariant.CustomerEntersPrice,
MinimumCustomerEnteredPrice = productVariant.MinimumCustomerEnteredPrice,
MaximumCustomerEnteredPrice = productVariant.MaximumCustomerEnteredPrice,
Weight = productVariant.Weight,
Length = productVariant.Length,
Width = productVariant.Width,
Height = productVariant.Height,
PictureId = pictureId,
AvailableStartDateTimeUtc = productVariant.AvailableStartDateTimeUtc,
AvailableEndDateTimeUtc = productVariant.AvailableEndDateTimeUtc,
Published = isPublished,
Deleted = productVariant.Deleted,
DisplayOrder = productVariant.DisplayOrder,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow
};
_productService.InsertProductVariant(productVariantCopy);
//localization
foreach (var lang in languages)
{
var name = productVariant.GetLocalized(x => x.Name, lang.Id, false, false);
if (!String.IsNullOrEmpty(name))
_localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Name, name, lang.Id);
var description = productVariant.GetLocalized(x => x.Description, lang.Id, false, false);
if (!String.IsNullOrEmpty(description))
_localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Description, description, lang.Id);
}
// product variant <-> attributes mappings
var associatedAttributes = new Dictionary<int, int>();
var associatedAttributeValues = new Dictionary<int, int>();
foreach (var productVariantAttribute in _productAttributeService.GetProductVariantAttributesByProductVariantId(productVariant.Id))
{
var productVariantAttributeCopy = new ProductVariantAttribute()
{
ProductVariantId = productVariantCopy.Id,
ProductAttributeId = productVariantAttribute.ProductAttributeId,
TextPrompt = productVariantAttribute.TextPrompt,
IsRequired = productVariantAttribute.IsRequired,
AttributeControlTypeId = productVariantAttribute.AttributeControlTypeId,
DisplayOrder = productVariantAttribute.DisplayOrder
};
_productAttributeService.InsertProductVariantAttribute(productVariantAttributeCopy);
//save associated value (used for combinations copying)
associatedAttributes.Add(productVariantAttribute.Id, productVariantAttributeCopy.Id);
// product variant attribute values
var productVariantAttributeValues = _productAttributeService.GetProductVariantAttributeValues(productVariantAttribute.Id);
foreach (var productVariantAttributeValue in productVariantAttributeValues)
{
var pvavCopy = new ProductVariantAttributeValue()
{
示例2: PrepareProductVariantModel
protected ProductModel.ProductVariantModel PrepareProductVariantModel(ProductModel.ProductVariantModel model, ProductVariant productVariant)
{
if (productVariant == null)
throw new ArgumentNullException("productVariant");
if (model == null)
throw new ArgumentNullException("model");
#region Properties
model.Id = productVariant.Id;
model.Name = productVariant.GetLocalized(x => x.Name);
model.ShowSku = _catalogSettings.ShowProductSku;
model.Sku = productVariant.Sku;
model.Description = productVariant.GetLocalized(x => x.Description);
model.ShowManufacturerPartNumber = _catalogSettings.ShowManufacturerPartNumber;
model.ManufacturerPartNumber = productVariant.ManufacturerPartNumber;
model.ShowGtin = _catalogSettings.ShowGtin;
model.Gtin = productVariant.Gtin;
model.StockAvailablity = productVariant.FormatStockMessage(_localizationService);
model.PictureModel.FullSizeImageUrl = _pictureService.GetPictureUrl(productVariant.PictureId, 0, false);
model.PictureModel.ImageUrl = _pictureService.GetPictureUrl(productVariant.PictureId, _mediaSetting.ProductVariantPictureSize, false);
model.PictureModel.Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name);
model.PictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name);
if (productVariant.IsDownload && productVariant.HasSampleDownload)
{
model.DownloadSampleUrl = Url.Action("Sample", "Download", new { productVariantId = productVariant.Id });
}
model.IsCurrentCustomerRegistered = _workContext.CurrentCustomer.IsRegistered();
//back in stock subscriptions)
if (productVariant.ManageInventoryMethod == ManageInventoryMethod.ManageStock &&
productVariant.BackorderMode == BackorderMode.NoBackorders &&
productVariant.AllowBackInStockSubscriptions &&
productVariant.StockQuantity <= 0)
{
//out of stock
model.DisplayBackInStockSubscription = true;
model.BackInStockAlreadySubscribed = _backInStockSubscriptionService.FindSubscription(_workContext.CurrentCustomer.Id, productVariant.Id) != null;
}
#endregion
#region Product variant price
model.ProductVariantPrice.ProductVariantId = productVariant.Id;
model.ProductVariantPrice.DynamicPriceUpdate = _catalogSettings.EnableDynamicPriceUpdate;
if (_permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
{
model.ProductVariantPrice.HidePrices = false;
if (productVariant.CustomerEntersPrice)
{
model.ProductVariantPrice.CustomerEntersPrice = true;
}
else
{
if (productVariant.CallForPrice)
{
model.ProductVariantPrice.CallForPrice = true;
}
else
{
decimal taxRate = decimal.Zero;
decimal oldPriceBase = _taxService.GetProductPrice(productVariant, productVariant.OldPrice, out taxRate);
decimal finalPriceWithoutDiscountBase = _taxService.GetProductPrice(productVariant, _priceCalculationService.GetFinalPrice(productVariant, false), out taxRate);
decimal finalPriceWithDiscountBase = _taxService.GetProductPrice(productVariant, _priceCalculationService.GetFinalPrice(productVariant, true), out taxRate);
decimal oldPrice = _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, _workContext.WorkingCurrency);
decimal finalPriceWithoutDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceWithoutDiscountBase, _workContext.WorkingCurrency);
decimal finalPriceWithDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceWithDiscountBase, _workContext.WorkingCurrency);
if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero)
model.ProductVariantPrice.OldPrice = _priceFormatter.FormatPrice(oldPrice);
model.ProductVariantPrice.Price = _priceFormatter.FormatPrice(finalPriceWithoutDiscount);
if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
model.ProductVariantPrice.PriceWithDiscount = _priceFormatter.FormatPrice(finalPriceWithDiscount);
model.ProductVariantPrice.PriceValue = finalPriceWithoutDiscount;
model.ProductVariantPrice.PriceWithDiscountValue = finalPriceWithDiscount;
}
}
}
else
{
model.ProductVariantPrice.HidePrices = true;
model.ProductVariantPrice.OldPrice = null;
model.ProductVariantPrice.Price = null;
}
#endregion
#region 'Add to cart' model
model.AddToCart.ProductVariantId = productVariant.Id;
//quantity
model.AddToCart.EnteredQuantity = productVariant.OrderMinimumQuantity;
//'add to cart', 'add to wishlist' buttons
model.AddToCart.DisableBuyButton = productVariant.DisableBuyButton || !_permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart);
model.AddToCart.DisableWishlistButton = productVariant.DisableWishlistButton || !_permissionService.Authorize(StandardPermissionProvider.EnableWishlist);
//.........这里部分代码省略.........