Create products from PHP in PrestaShop
In this video we will see how to create a simple script to generate products with PHP in PrestaShop
Watch the screencast
Final Code
<?php
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
// we have a csv file open
$default_lang = Configuration::get('PS_LANG_DEFAULT');
// looping through products
// this is a single line in the loop
$product = new Product(20);
$product->name = [$default_lang => 'Test'];
$product->link_rewrite = [$default_lang => 'test'];
$product->price = 13.90;
$product->quantity = 70;
$product->id_category = [3,4];
$product->id_category_default = 3;
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, Context::getContext()->shop->id);
$product->update();



