您可以使用prestashop站點中的腳本從外部數據庫添加類別。爲此,創建一個帶前臺控制器(用於cron作業或運行腳本)的模塊,並在腳本內部從外部數據庫中選擇類別,然後遍歷類別和循環內部的內容創建prestashop類別對象,並將類別字段放入類別對象並調用類別保存方法。
public function initContent()
{
parent::initContent();
$temp_categs = array(); //
//fetch data into $temp_catgs from the external db with the help mysqli_connect or whatever the driver - never modify presta db settings - write php code for db connection to external db and fetch
//loop through the fetched categories
foreach($temp_categs as $categ){
$new_categ = new Category();
//set all the field values
$new_categ->name = $categ['name'];
$new_categ->id_parent = $categ['id_parent'];
$new_categ->active = true;
$new_categ->field2 = $categ['field2'];
$new_categ->field3 = $categ['field3'];
//save the category - a category with new id will be created in prestashop
$new_categ->save();
}
}
}
我希望這會幫助你。
您可以創建一個腳本來導入您的產品/類別/客戶端到prestashop,您可以通過從ERP軟件創建一個csv文件來完成,也可以通過webservice進行導入,在這種情況下您應該使用xml文件 –