Categories with the same name are not supported in the same category level. Check your category list in "Catalog -> Categories" page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 years ago
Hi there,

Could someone please help me?

I am receiving this message when I try to import products using excel.

Categories with the same name are not supported in the same category level. Check your category list in "Catalog -> Categories" page

System.ArgumentException: Categories with the same name are not supported in the same category level. Check your category list in "Catalog -> Categories" page
   at Nop.Services.ExportImport.ImportManager.ImportProductsFromXlsx(Stream stream)
   at Nop.Web.Areas.Admin.Controllers.ProductController.ImportExcel(IFormFile importexcelfile)

I've tried everything.. I even tried to create many category names but it just keep sending me the same error.

Could someone please help?

Thanks so much
2 years ago
Check your db. Is any duplicate category name present at same level or not

WITH CTECategoryHierarchy(LeafCategoryId, FullName) AS (
  SELECT Id, CAST(Name as NVARCHAR(MAX)) FROM Category WITH (NOLOCK) WHERE ParentCategoryId = 0 AND Deleted = 0
  UNION ALL
  SELECT c.Id, h.FullName+' > '+c.Name
  FROM Category c WITH (NOLOCK)
  JOIN CTECategoryHierarchy h ON h.LeafCategoryId = c.ParentCategoryId
),
CTEFinalData AS(
SELECT c2.Id, c2.Name, cs.cts.query('root').value('.[1]', 'nvarchar(max)') AS 'CategoryHierarchy'
FROM [dbo].Category c2
CROSS APPLY (SELECT ch.FullName + '; '
        FROM Category c1
        JOIN CTECategoryHierarchy ch WITH (NOLOCK) ON c1.Id = ch.LeafCategoryId
                WHERE  c1.Id = c2.Id
        order by c1.Id
                FOR XML PATH(''), root('root'), type) cs (cts)
        WHERE c2.Deleted = 0 AND (SELECT COUNT(Id) from Category c WHERE c.ParentCategoryId = c2.Id) = 0),
        MultipleCategory AS (
    SELECT
        cc.*,
        ROW_NUMBER() OVER (
            PARTITION BY
                [Name],
                CategoryHierarchy
            ORDER BY
                [Name]
        ) Total_Count
     FROM
        CTEFinalData cc
)
SELECT * from MultipleCategory where Total_Count > 1 order by Total_Count desc

Orginal post link https://www.nopcommerce.com/en/boards/topic/71329/import-products-by-excel-sheet#294783
2 years ago
I had a similar issue with importing some products and used the following to inspect the category table.

Go
SELECT Count(name) From dbo.Category
WHERE Deleted = 0
Go
SELECT DISTINCT COUNT(Name) FROM dbo.Category
WHERE Deleted = 0
Go
Select Name from dbo.Category
WHERE Deleted = 0
Order By Name

Although my categories are not extremely elaborate to just visually look for the duplicated category.
Mine ultimately ended up being a sku number duplicated along with  the category name duplication where one was suppose to be deleted and somehow both the categories with the same name were published. Which I believe is something I accidentally set in my importing of records inadvertently.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.