This Laravel application allows you to import product data from an Excel file into a database, validating against unique SKUs and sending email notifications for duplicate SKUs.
- PHP (7.3 or later)
- Composer
- MySQL or another database system
- SMTP-enabled email account (Gmail recommended)
- Clone the repository:
git clone https://github.com/your-username/product-importer.git
cd product-importer
- Install the dependencies:
composer install
- Copy the
.env.example
file to.env
and configure it with your environment details:
cp .env.example .env
Update the following settings:
DB_CONNECTION
,DB_HOST
,DB_PORT
,DB_DATABASE
,DB_USERNAME
,DB_PASSWORD
for your database.MAIL_MAILER
,MAIL_HOST
,MAIL_PORT
,MAIL_USERNAME
,MAIL_PASSWORD
for your email configuration.
- Generate the application key:
php artisan key:generate
- Run migrations to create the necessary database tables:
php artisan migrate
- Start the development server:
php artisan serve
- Access the application by visiting http://127.0.0.1:8000 in your browser.
- On the web page, you can upload an Excel file containing product data. The expected CSV format is as follows:
CSV File Structure:
Your CSV file should contain the following columns:
- Title
- Description(body)
- SKU(handle)
- Type
- Publish Status
- Sample CSV File: You can download a sample CSV file from this link to better understand the expected format.
Ensure that the CSV file has column names corresponding to the ones listed above.
- Before importing, make sure to update the
.env
file with your custom email and password, and the database name. - Upon import, the application will validate for unique SKUs. If a duplicate SKU is found, an email notification will be sent to the configured email address (customizable in the
ProductImport
class).
- Customize the validation rules, email content, and other import-related logic in the
ProductImport
class (app/Imports/ProductImport.php
). - Customize the email content and layout in the
DuplicateSkuNotification
Mailable class (app/Mail/DuplicateSkuNotification.php
).
- If you encounter issues, ensure that you have correctly configured the
.env
file with the appropriate database and email settings.
Contributions are welcome! If you find a bug or have an enhancement in mind, feel free to submit a pull request.
This project is licensed under the MIT License.