PrestaShop Product Import/Export Setup
PrestaShop has built-in import in Advanced Parameters → Import. For production tasks with 5,000+ products, the built-in tool requires tuning or replacement with a custom batch solution with memory management.
CSV Structure for Product Import
PrestaShop importer expects fixed fields. Delimiter and encoding configurable on upload:
ID;Active (0/1);Name *;Categories;Price tax excl.;Tax rules ID;Wholesale price;On sale (0/1);Discount amount;Discount percent;Discount from (yyyy-mm-dd);Discount to (yyyy-mm-dd);Reference #;Supplier reference #;Supplier;Brand;EAN13;UPC;MPN;Ecotax;Weight;Quantity;Description;Short description;Tags (x,y,z...);Meta title;Meta description;URL rewritten;Image URLs (x,y,z...);Image alt texts (x,y,z...);Feature (Name:Value:Position:Customized);Available for order;Available date;Show price;Visibility;Additional shipping cost;Unity;Unit price;Summary;Shop (for multi-shop only)
;1;Winter Men's Jacket;Outerwear,Men's Clothing;2999.00;1;0;0;0;0;;;ART-001;;Brand;JacketBrand;4607167430120;;;0;1.5;50;"Full jacket description...";"Winter jacket";"jacket, winter, men";"Buy men's winter jacket";"Winter men's jacket — buy";"winter-jacket-mens";"https://cdn.example.com/img1.jpg,https://cdn.example.com/img2.jpg";"Jacket view 1,Jacket view 2";"Color:Black:1:0;Size:L:2:0";1;;;1;everywhere;0;;;
Configuration for Bulk Import
Default PHP import process hits memory_limit and max_execution_time. For 10,000+ row files:
// override/controllers/admin/AdminImportController.php
class AdminImportControllerCore extends AdminImportController
{
public function __construct()
{
parent::__construct();
@ini_set('memory_limit', '512M');
@ini_set('max_execution_time', '3600');
}
// Reduce batch size to save memory
const MAX_LINE_SIZE = 4096; // bytes per line
}
Or via PHP-FPM pool configuration for import processes:
; /etc/php/8.1/fpm/pool.d/prestashop-import.conf
[prestashop-import]
pm = static
pm.max_children = 2
php_value[memory_limit] = 1G
php_value[max_execution_time] = 7200
Programmatic Import via ObjectModel
For ERP/1C integration, bypass web importer and work directly via PrestaShop API:
// Import product with attributes
class ProductImporter
{
private int $defaultLangId;
private int $shopId;
public function importProduct(array $data): int
{
$product = new Product();
$product->name[$this->defaultLangId] = $data['name'];
$product->description[$this->defaultLangId] = $data['description'];
$product->description_short[$this->defaultLangId] = $data['short_description'];
$product->link_rewrite[$this->defaultLangId] = Tools::link_rewrite($data['name']);
$product->reference = $data['sku'];
$product->price = (float) $data['price'];
$product->weight = (float) ($data['weight'] ?? 0);
$product->active = 1;
$product->id_category_default = $data['category_id'];
$product->id_shop_default = $this->shopId;
if (!$product->add()) {
throw new \RuntimeException('Failed to add product: ' . $data['sku']);
}
// Bind to categories
$product->addToCategories($data['category_ids']);
// Update stock
StockAvailable::setQuantity($product->id, 0, (int) $data['qty']);
// Index after addition
Search::indexation(false, $product->id);
return (int) $product->id;
}
public function importImage(int $productId, string $imageUrl, string $legend = ''): void
{
$image = new Image();
$image->id_product = $productId;
$image->position = Image::getHighestPosition($productId) + 1;
$image->cover = !Image::getCover($productId);
$image->add();
$imageFile = _PS_PRODUCT_IMG_DIR_ . $image->getImgPath() . '.jpg';
Tools::copy($imageUrl, $imageFile);
$imageObj = new ImageManager();
$imageObj->resize($imageFile, $imageFile, null, null, 'jpg', false, $error, null, 95, true);
Image::generateImgSize($imageFile, $image->id_product, $image->id);
}
}
Export via WebService API
PrestaShop WebService provides REST API for export:
# Get product list via WebService
curl "https://example.com/api/products?ws_key=YOUR_API_KEY&output_format=JSON&limit=100&page=1&display=full"
# Filter by modification date
curl "https://example.com/api/products?ws_key=KEY&output_format=JSON&filter[date_upd]=[2024-01-01,2024-12-31]&date=1"
PHP client for systematic export:
$client = new PrestaShopWebservice('https://example.com', 'YOUR_API_KEY', false);
$params = [
'resource' => 'products',
'display' => '[id,reference,name,price,quantity]',
'sort' => '[id_ASC]',
'limit' => '100,100', // offset=100, limit=100
];
$xml = $client->get($params);
$products = $xml->products->product;
Configure Import Module for Cron
For regular catalog updates from external source:
// modules/erpimport/cron.php
define('_PS_ADMIN_DIR_', getcwd());
include(dirname(__FILE__) . '/../../config/config.inc.php');
$importer = new ErpProductImporter();
$products = $importer->fetchFromErp(strtotime('-1 hour')); // modified in last hour
foreach (array_chunk($products, 100) as $batch) {
foreach ($batch as $productData) {
try {
$importer->upsert($productData);
} catch (Exception $e) {
PrestaShopLogger::addLog(
'ERP import error: ' . $e->getMessage(),
3, // severity: error
null, 'Product', $productData['id'] ?? 0
);
}
}
// Pause between batches to reduce load
usleep(100000); // 100ms
}
# Cron entry
*/30 * * * * www-data php /var/www/prestashop/modules/erpimport/cron.php >> /var/log/prestashop/erp-import.log 2>&1
Timeline
- Configure built-in importer + test import: 4–8 hours
- Custom importer with ERP integration: 3–7 days
- Regular sync setup with error monitoring: 2–3 days
- Migrate 10,000+ SKU catalog with images: 3–7 days







