本文整理汇总了C#中Nop.Core.Domain.Catalog.Product.FormatStockMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Product.FormatStockMessage方法的具体用法?C# Product.FormatStockMessage怎么用?C# Product.FormatStockMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Catalog.Product
的用法示例。
在下文中一共展示了Product.FormatStockMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareProductDetailsPageModel
protected ProductDetailsModel PrepareProductDetailsPageModel(Product product, bool isAssociatedProduct = false)
{
if (product == null)
throw new ArgumentNullException("product");
#region Standard properties
var model = new ProductDetailsModel()
{
Id = product.Id,
Name = product.GetLocalized(x => x.Name),
ShortDescription = product.GetLocalized(x => x.ShortDescription),
FullDescription = product.GetLocalized(x => x.FullDescription),
MetaKeywords = product.GetLocalized(x => x.MetaKeywords),
MetaDescription = product.GetLocalized(x => x.MetaDescription),
MetaTitle = product.GetLocalized(x => x.MetaTitle),
SeName = product.GetSeName(),
ShowSku = _catalogSettings.ShowProductSku,
Sku = product.Sku,
ShowManufacturerPartNumber = _catalogSettings.ShowManufacturerPartNumber,
ManufacturerPartNumber = product.ManufacturerPartNumber,
ShowGtin = _catalogSettings.ShowGtin,
Gtin = product.Gtin,
StockAvailability = product.FormatStockMessage(_localizationService),
HasSampleDownload = product.IsDownload && product.HasSampleDownload,
IsCurrentCustomerRegistered = _workContext.CurrentCustomer.IsRegistered(),
};
#endregion
#region Back in stock subscriptions
if (product.ManageInventoryMethod == ManageInventoryMethod.ManageStock &&
product.BackorderMode == BackorderMode.NoBackorders &&
product.AllowBackInStockSubscriptions &&
product.StockQuantity <= 0)
{
//out of stock
model.DisplayBackInStockSubscription = true;
model.BackInStockAlreadySubscribed = _backInStockSubscriptionService
.FindSubscription(_workContext.CurrentCustomer.Id, product.Id, _storeContext.CurrentStore.Id) != null;
}
#endregion
#region Templates
var templateCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_TEMPLATE_MODEL_KEY, product.ProductTemplateId);
model.ProductTemplateViewPath = _cacheManager.Get(templateCacheKey, () =>
{
var template = _productTemplateService.GetProductTemplateById(product.ProductTemplateId);
if (template == null)
template = _productTemplateService.GetAllProductTemplates().FirstOrDefault();
if (template == null)
throw new Exception("No default template could be loaded");
return template.ViewPath;
});
#endregion
#region Pictures
model.DefaultPictureZoomEnabled = _mediaSettings.DefaultPictureZoomEnabled;
var pictures = _pictureService.GetPicturesByProductId(product.Id);
//default picture
var defaultPictureSize = isAssociatedProduct ?
_mediaSettings.AssociatedProductPictureSize :
_mediaSettings.ProductDetailsPictureSize;
model.DefaultPictureModel = new PictureModel()
{
ImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), defaultPictureSize, !isAssociatedProduct),
FullSizeImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), 0, !isAssociatedProduct),
Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
};
//all pictures
foreach (var picture in pictures)
{
model.PictureModels.Add(new PictureModel()
{
ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSettings.ProductThumbPictureSizeOnProductDetailsPage),
FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
});
}
#endregion
#region Product price
model.ProductPrice.ProductId = product.Id;
model.ProductPrice.DynamicPriceUpdate = _catalogSettings.EnableDynamicPriceUpdate;
if (_permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
{
model.ProductPrice.HidePrices = false;
if (product.CustomerEntersPrice)
{
model.ProductPrice.CustomerEntersPrice = true;
}
//.........这里部分代码省略.........
示例2: PrepareProductDetailsPageModel
protected virtual ProductDetailsModel PrepareProductDetailsPageModel(Product product,
ShoppingCartItem updatecartitem = null, bool isAssociatedProduct = false)
{
if (product == null)
throw new ArgumentNullException("product");
#region Standard properties
var model = new ProductDetailsModel
{
Id = product.Id,
Name = product.GetLocalized(x => x.Name),
ShortDescription = product.GetLocalized(x => x.ShortDescription),
FullDescription = product.GetLocalized(x => x.FullDescription),
MetaKeywords = product.GetLocalized(x => x.MetaKeywords),
MetaDescription = product.GetLocalized(x => x.MetaDescription),
MetaTitle = product.GetLocalized(x => x.MetaTitle),
SeName = product.GetSeName(),
ShowSku = _catalogSettings.ShowProductSku,
Sku = product.Sku,
ShowManufacturerPartNumber = _catalogSettings.ShowManufacturerPartNumber,
FreeShippingNotificationEnabled = _catalogSettings.ShowFreeShippingNotification,
ManufacturerPartNumber = product.ManufacturerPartNumber,
ShowGtin = _catalogSettings.ShowGtin,
Gtin = product.Gtin,
StockAvailability = product.FormatStockMessage("", _localizationService, _productAttributeParser),
HasSampleDownload = product.IsDownload && product.HasSampleDownload,
DisplayDiscontinuedMessage = !product.Published && _catalogSettings.DisplayDiscontinuedMessageForUnpublishedProducts
};
//automatically generate product description?
if (_seoSettings.GenerateProductMetaDescription && String.IsNullOrEmpty(model.MetaDescription))
{
//based on short description
model.MetaDescription = model.ShortDescription;
}
//shipping info
model.IsShipEnabled = product.IsShipEnabled;
if (product.IsShipEnabled)
{
model.IsFreeShipping = product.IsFreeShipping;
//delivery date
var deliveryDate = _shippingService.GetDeliveryDateById(product.DeliveryDateId);
if (deliveryDate != null)
{
model.DeliveryDate = deliveryDate.GetLocalized(dd => dd.Name);
}
}
//email a friend
model.EmailAFriendEnabled = _catalogSettings.EmailAFriendEnabled;
//compare products
model.CompareProductsEnabled = _catalogSettings.CompareProductsEnabled;
#endregion
#region Vendor details
//vendor
if (_vendorSettings.ShowVendorOnProductDetailsPage)
{
var vendor = _vendorService.GetVendorById(product.VendorId);
if (vendor != null && !vendor.Deleted && vendor.Active)
{
model.ShowVendor = true;
model.VendorModel = new VendorBriefInfoModel
{
Id = vendor.Id,
Name = vendor.GetLocalized(x => x.Name),
SeName = vendor.GetSeName(),
};
}
}
#endregion
#region Page sharing
if (_catalogSettings.ShowShareButton && !String.IsNullOrEmpty(_catalogSettings.PageShareCode))
{
var shareCode = _catalogSettings.PageShareCode;
if (_webHelper.IsCurrentConnectionSecured())
{
//need to change the addthis link to be https linked when the page is, so that the page doesnt ask about mixed mode when viewed in https...
shareCode = shareCode.Replace("http://", "https://");
}
model.PageShareCode = shareCode;
}
#endregion
#region Back in stock subscriptions
if (product.ManageInventoryMethod == ManageInventoryMethod.ManageStock &&
//.........这里部分代码省略.........
示例3: PrepareProductDetailsPageModel
protected ProductDetailsModel PrepareProductDetailsPageModel(Product product,
ShoppingCartItem updatecartitem = null, bool isAssociatedProduct = false)
{
if (product == null)
throw new ArgumentNullException("product");
#region Standard properties
var model = new ProductDetailsModel()
{
Id = product.Id,
Name = product.GetLocalized(x => x.Name),
ShortDescription = product.GetLocalized(x => x.ShortDescription),
FullDescription = product.GetLocalized(x => x.FullDescription),
MetaKeywords = product.GetLocalized(x => x.MetaKeywords),
MetaDescription = product.GetLocalized(x => x.MetaDescription),
MetaTitle = product.GetLocalized(x => x.MetaTitle),
SeName = product.GetSeName(),
ShowSku = _catalogSettings.ShowProductSku,
Sku = product.Sku,
ShowManufacturerPartNumber = _catalogSettings.ShowManufacturerPartNumber,
FreeShippingNitificationEnabled = _catalogSettings.ShowFreeShippingNotification,
ManufacturerPartNumber = product.ManufacturerPartNumber,
ShowGtin = _catalogSettings.ShowGtin,
Gtin = product.Gtin,
StockAvailability = product.FormatStockMessage(_localizationService),
HasSampleDownload = product.IsDownload && product.HasSampleDownload,
IsCurrentCustomerRegistered = _workContext.CurrentCustomer.IsRegistered(),
};
//vendor
if (_vendorSettings.ShowVendorOnProductDetailsPage)
{
var vendor = _vendorService.GetVendorById(product.VendorId);
if (vendor != null && vendor.Active)
{
model.ShowVendor = true;
model.VendorModel.Id = vendor.Id;
model.VendorModel.Name = vendor.Name;
model.VendorModel.SeName = SeoExtensions.GetSeName(vendor.Name);
}
}
model.IsShipEnabled = product.IsShipEnabled;
if (product.IsShipEnabled)
{
model.IsFreeShipping = product.IsFreeShipping;
//delivery date
var deliveryDate = _shippingService.GetDeliveryDateById(product.DeliveryDateId);
if (deliveryDate != null)
{
model.DeliveryDate = deliveryDate.GetLocalized(dd => dd.Name);
}
}
#endregion
#region Back in stock subscriptions
if (product.ManageInventoryMethod == ManageInventoryMethod.ManageStock &&
product.BackorderMode == BackorderMode.NoBackorders &&
product.AllowBackInStockSubscriptions &&
product.StockQuantity <= 0)
{
//out of stock
model.DisplayBackInStockSubscription = true;
model.BackInStockAlreadySubscribed = _backInStockSubscriptionService
.FindSubscription(_workContext.CurrentCustomer.Id, product.Id, _storeContext.CurrentStore.Id) != null;
}
#endregion
#region Templates
var templateCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_TEMPLATE_MODEL_KEY, product.ProductTemplateId);
model.ProductTemplateViewPath = _cacheManager.Get(templateCacheKey, () =>
{
var template = _productTemplateService.GetProductTemplateById(product.ProductTemplateId);
if (template == null)
template = _productTemplateService.GetAllProductTemplates().FirstOrDefault();
if (template == null)
throw new Exception("No default template could be loaded");
return template.ViewPath;
});
#endregion
#region Pictures
model.DefaultPictureZoomEnabled = _mediaSettings.DefaultPictureZoomEnabled;
//default picture
var defaultPictureSize = isAssociatedProduct ?
_mediaSettings.AssociatedProductPictureSize :
_mediaSettings.ProductDetailsPictureSize;
//prepare picture models
var productPicturesCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DETAILS_PICTURES_MODEL_KEY, product.Id, defaultPictureSize, isAssociatedProduct, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id);
var cachedPictures = _cacheManager.Get(productPicturesCacheKey, () =>
{
var pictures = _pictureService.GetPicturesByProductId(product.Id);
//.........这里部分代码省略.........