This Python script reads product data from an Excel file, processes it through Google's Gemini LLM to generate WooCommerce-compatible descriptions and attributes, and then adds the products to a WooCommerce store via API.
- Reads product data from Excel files with flexible column naming
- Uses Google Gemini AI to generate product descriptions and attributes
- Converts raw product features into structured WooCommerce attributes
- Adds products to WooCommerce via REST API
- Comprehensive error handling and logging
- Rate limiting to avoid API throttling
- Python 3.8+
- WooCommerce store with REST API enabled
- Google Gemini AI API key
- Excel file with product data
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt
-
Edit
.envfile with your actual credentials:WOOCOMMERCE_URL=https://yourstore.com WOOCOMMERCE_CONSUMER_KEY=ck_your_consumer_key WOOCOMMERCE_CONSUMER_SECRET=cs_your_consumer_secret GEMINI_API_KEY=your_gemini_api_key
Your Excel file should have these columns (column names are flexible):
- Product Name (or "name", "product_name")
- Raw Features (or "features", "raw_features")
- Price (numeric)
- Regular Price (or "regular_price", numeric)
-
Place your Excel file in the same directory as the script and name it
data/products.xlsx(or modify the script to use a different filename) -
Run the script:
python product_loader.py
The script will:
- Read products from the Excel file
- Process each product through Gemini AI to generate:
- Slug
- Detailed description
- Short description
- Structured attributes
- Add each product to your WooCommerce store
- Go to your WordPress admin panel
- Navigate to WooCommerce > Settings > Advanced > REST API
- Click "Add Key"
- Set permissions to "Read/Write"
- Copy the Consumer Key and Consumer Secret to your
.envfile
- Go to Google AI Studio
- Create a new API key
- Copy the API key to your
.envfile
Note: This script uses the new google-genai package with the Gemini 2.5 Flash model for improved performance.
This project is open source and available under the MIT License.