grandnode2 icon indicating copy to clipboard operation
grandnode2 copied to clipboard

ProductType value 15, 25 are not present in the enum ProductType. Is it a defect or intentionally kept?

Open Nikhil13x opened this issue 2 years ago • 1 comments

https://github.com/grandnode/grandnode2/blob/50e28d6ea38db02f6780303a1602cf6ad3d671cd/src/Web/Grand.Web/Views/Catalog/Partials/CatalogProductGridView.cshtml#L67

Nikhil13x avatar Jun 14 '23 08:06 Nikhil13x

Hi @Nikhil13x

This is most probably an error since the beginning of GrandNode2.

I had the same question so I looked into the source code of previous GrandNode version. According to GrandNode source code, ProductType 15 and 25 were Reservation and Auction respectively:

https://github.com/grandnode/grandnode/blob/c209758031e88d0279a023a7237b1f68ebd9f4dc/Grand.Domain/Catalog/ProductType.cs

namespace Grand.Domain.Catalog
{
    /// <summary>
    /// Represents a product type
    /// </summary>
    public enum ProductType
    {
        /// <summary>
        /// Simple
        /// </summary>
        SimpleProduct = 5,
        /// <summary>
        /// Grouped (product with variants)
        /// </summary>
        GroupedProduct = 10,

        /// <summary>
        /// Reservation product
        /// </summary>
        Reservation = 15,

        /// <summary>
	/// Bundled product
	/// </summary>
	BundledProduct = 20,

        /// <summary>
        /// Auction
        /// </summary>
        Auction = 25
    }
}

This could be fixed with a simple replacement but there might be other places where the old values still remains, like:

https://github.com/grandnode/grandnode2/blob/7122ed404a4cf7ae7d25617d5af9e7751e1f78b6/src/Web/Grand.Web/Views/Catalog/Partials/CatalogProductListView.cshtml#L67-L68 https://github.com/grandnode/grandnode2/blob/7122ed404a4cf7ae7d25617d5af9e7751e1f78b6/src/Web/Grand.Web/Views/Shared/Partials/QuickView/RelatedProductView.cshtml#L66-L67

An improvement could be to replace those "magic numbers" with an int cast of the corresponding ProductType enum value or a well named constant in the .js files.

TheFlo avatar Dec 03 '24 07:12 TheFlo