MNB PHPExcelDeveloper Guide
v2.0.5
Imports

Domain Import APIs

Use typed presets for common business, education, CRM, ecommerce, and content imports.

Updated

LevelIntermediateReading time13 minPackagemnb/mnb-phpexcel
importProducts()importUsers()importOrders()importInventory()importDomain()

What you will learn

  • Use a preset instead of rebuilding common mappings and rules.
  • Override aliases, rules, defaults, transformations, and duplicate keys.
  • Generate matching templates and previews from the same domain schema.

Domain imports add common aliases, canonical fields, normalization, validation, cross-field rules, duplicate keys, previews, templates, and progress on top of the generic SQL engine.

PresetConvenience methodTypical unique key
UsersimportUsers()email / username
ProductsimportProducts()sku
OrdersimportOrders()order number
InventoryimportInventory()sku + location
StudentsimportStudents()student id
AttendanceimportAttendance()person + date
MarksimportMarks()student + subject
ContactsimportContacts()email / phone
LocationsimportLocations()code / coordinates
Blog postsimportBlogPosts()slug
Media pathsimportMedia()path / URL
CategoriesimportCategories()slug / code

Complete example

Import products
$result = MnbExcel::importProducts(
    'products.xlsx',
    $pdo,
    'products',
    [
        'batch_size' => 1000,
        'duplicate_strategy' => 'update',
        'unique_by' => ['sku'],
        'failed_rows_csv' => __DIR__ . '/failed-products.csv',
    ]
);

Override the preset

Presets are defaults, not locked schemas. Override mappings, aliases, rules, defaults, normalizers, transformations, unique keys, duplicate behavior, sheet selection, progress, and failed-row paths per application.