Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor changes in ProductAttributeFormatter

support5e964ceffa4c
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeFormatter.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeFormatter.cs
index 28fcb8e70..aa81bfa5e 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeFormatter.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeFormatter.cs
@@ -3,7 +3,6 @@ using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -24,7 +23,6 @@ namespace Grand.Business.Catalog.Services.Products
private readonly ITranslationService _translationService;
private readonly ITaxService _taxService;
private readonly IPriceFormatter _priceFormatter;
- private readonly IDownloadService _downloadService;
private readonly IPricingService _pricingService;
private readonly IProductService _productService;
@@ -34,7 +32,6 @@ namespace Grand.Business.Catalog.Services.Products
ITranslationService translationService,
ITaxService taxService,
IPriceFormatter priceFormatter,
- IDownloadService downloadService,
IPricingService priceCalculationService,
IProductService productService)
{
@@ -44,7 +41,6 @@ namespace Grand.Business.Catalog.Services.Products
_translationService = translationService;
_taxService = taxService;
_priceFormatter = priceFormatter;
- _downloadService = downloadService;
_pricingService = priceCalculationService;
_productService = productService;
}
@@ -202,31 +198,23 @@ namespace Grand.Business.Catalog.Services.Products
else if (attribute.AttributeControlTypeId == AttributeControlType.FileUpload)
{
//file upload
- Guid downloadGuid;
- Guid.TryParse(valueStr, out downloadGuid);
- var download = await _downloadService.GetDownloadByGuid(downloadGuid);
- if (download != null)
+ _ = Guid.TryParse(valueStr, out var downloadGuid);
+ var attributeName = productAttribute.GetTranslation(a => a.Name, langId);
+ var attributeText = "";
+ if (allowHyperlinks)
{
- string attributeText = "";
- var fileName = string.Format("{0}{1}", download.Filename ?? download.DownloadGuid.ToString(), download.Extension);
- if (htmlEncode)
- fileName = WebUtility.HtmlEncode(fileName);
- if (allowHyperlinks)
- {
- var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentHost.Url.TrimEnd('/'), download.DownloadGuid);
- attributeText = string.Format("<a href=\"{0}\" class=\"fileuploadattribute\">{1}</a>", downloadLink, fileName);
- }
- else
- {
- //hyperlinks aren't allowed
- attributeText = fileName;
- }
- var attributeName = productAttribute.GetTranslation(a => a.Name, langId);
- //encode (if required)
- if (htmlEncode)
- attributeName = WebUtility.HtmlEncode(attributeName);
- formattedAttribute = string.Format("{0}: {1}", attributeName, attributeText);
+ var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentHost.Url.TrimEnd('/'), downloadGuid);
+ attributeText = string.Format("<a href=\"{0}\" class=\"fileuploadattribute\">{1}</a>", downloadLink, attributeName);
}
+ else
+ {
+ //hyperlinks aren't allowed
+ attributeText = attributeName;
+ }
+ //encode
+ if (htmlEncode)
+ attributeName = WebUtility.HtmlEncode(attributeName);
+ formattedAttribute = string.Format("{0}: {1}", attributeName, attributeText);
}
else
{