How can I check in code if it is Grouped Product? I want to use it in _ProductBox.cshtml
I need the code example like this:
@if (Model.GroupedProduct) {
<div class="note">This is Grouped Product.</div>
}
Thanks.
<!-- Availability -->
@if (stockMessage.Equals(localizationService.GetResource("Products.Availability.OutOfStock")))
{
<div class="out-of-stock">@stockMessage</div>
}
else
{
<div class="in-stock">@stockMessage</div>
}
var productService = EngineContext.Current.Resolve<IProductService>();
var localizationService = EngineContext.Current.Resolve<ILocalizationService>();
var productAttributeParser = EngineContext.Current.Resolve<IProductAttributeParser>();
var dateRangeService = EngineContext.Current.Resolve<IDateRangeService>();
var stockMessage = string.Empty;
var currentProduct = productService.GetProductById(Model.Id);
if(currentProduct.ProductType == ProductType.SimpleProduct)
{
stockMessage = currentProduct.FormatStockMessage("", localizationService,
productAttributeParser, dateRangeService);
}
else
{
var associatedProducts = productService.GetAssociatedProducts(currentProduct.Id);
foreach (var ap in associatedProducts)
{
stockMessage = ap.FormatStockMessage("", localizationService,
productAttributeParser, dateRangeService);
if (stockMessage.Equals(localizationService.GetResource("Products.Availability.InStock")))
{
break;
}
}
}
}