nopSolutions/nopCommerce · error · Exception

"{mName}" manufacturer could not be loaded

Error message

"{mName}" manufacturer could not be loaded

What it means

Thrown by getManufacturerId during sample-product installation. It looks up a Manufacturer by name; a null result means the referenced manufacturer does not exist, so sample products cannot be linked to it. As with sibling lookups, it indicates manufacturer seeding was skipped or the sample data references an unknown name.

Source

Thrown at src/Libraries/Nop.Services/Installation/InstallSampleData.Products.cs:145

                    throw new Exception($"\"{tName}\" template could not be loaded"));
        }

        async Task<int> getTaxCategoryId(string taxCategoryName)
        {
            return await getAndSaveId(taxCategories, taxCategoryName, async tcName => await GetFirstEntityIdAsync<TaxCategory>(tc => tc.Name == tcName) ??
                throw new Exception($"\"{tcName}\" tax category could not be loaded"));
        }

        async Task<int> getCategoryId(string categoryName)
        {
            return await getAndSaveId(categories, categoryName, async cName => await GetFirstEntityIdAsync<Category>(c => c.Name == cName) ??
                throw new Exception($"\"{cName}\" category could not be loaded"));
        }

        async Task<int> getManufacturerId(string manufacturerName)
        {
            return await getAndSaveId(manufacturers, manufacturerName, async mName => await GetFirstEntityIdAsync<Manufacturer>(m => m.Name == mName) ??
                throw new Exception($"\"{mName}\" manufacturer could not be loaded"));
        }

        async Task<int> getProductAttributeId(string productAttributeName)
        {
            return await getAndSaveId(productAttributes, productAttributeName, async paName => await GetFirstEntityIdAsync<ProductAttribute>(pa => pa.Name == paName) ??
                throw new Exception($"\"{paName}\" product attribute could not be loaded"));
        }

        async Task<int> getProductAvailabilityRangeId(string productAvailabilityRangeName)
        {
            return await getAndSaveId(productAvailabilityRanges, productAvailabilityRangeName, async parName => await GetFirstEntityIdAsync<ProductAvailabilityRange>(par => par.Name == parName) ??
                throw new Exception($"\"{parName}\" product availability range could not be loaded"));
        }

        async Task<int> getDeliveryDateId(string deliveryDateName)
        {
            return await getAndSaveId(deliveryDates, deliveryDateName, async ddName => await GetFirstEntityIdAsync<DeliveryDate>(dd => dd.Name == ddName) ??
                throw new Exception($"\"{ddName}\" delivery date could not be loaded"));

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Run the manufacturer-seeding install step before sample product install.
  2. Verify referenced Manufacturer names exist before installing sample products.
  3. Correct manufacturer-name typos in the sample-data source.
  4. Reinstall from a clean database.

Example fix

// before
async mName => await GetFirstEntityIdAsync<Manufacturer>(m => m.Name == mName)
    ?? throw new Exception($"\"{mName}\" manufacturer could not be loaded")

// after
var id = await GetFirstEntityIdAsync<Manufacturer>(m => m.Name == manufacturerName);
if (id == 0)
    throw new InvalidOperationException($"Manufacturer '{manufacturerName}' not found. Seed manufacturers first.");
Defensive patterns

Strategy: validation

Validate before calling

// Verify referenced manufacturers exist before sample install
var needed = new[] { "Acme", "Globex" };
var missing = needed.Except(await Table<Manufacturer>().Select(m => m.Name).ToListAsync());
if (missing.Any())
    throw new InvalidOperationException($"Missing manufacturers: {string.Join(", ", missing)}");

Type guard

static async Task<bool> ManufacturerExistsAsync(IRepository<Manufacturer> repo, string name)
    => await repo.Table.AnyAsync(m => m.Name == name);

Try / catch

try { await getManufacturerId(name); }
catch (Exception ex) when (ex.Message.Contains("manufacturer could not be loaded"))
{ /* log missing name + available manufacturers; abort sample install */ }

Prevention

When it happens

Trigger: Installing sample products referencing a Manufacturer name not present in the DB; running product sample install before manufacturer seeding; a name mismatch in the sample data.

Common situations: Partial install missing manufacturer seeding; reordering of install steps; custom sample-data file with wrong manufacturer names.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/8a29cc1306cade93. Report an issue: GitHub.