2015-07-03 86 views
0

我有一個雜貨店,我想在網上銷售這個產品。所以我使用了一個名爲「prestashop」的CMS購物車。如何從外部數據庫更新prestashop產品詳細信息?

即使我已經安裝並開始工作,但我有一些問題。

  1. 我有我自己的庫存數據庫來存儲所有產品詳細信息。與我可以添加產品詳細信息到數據庫(數量,價格等)的用戶界面。現在我的問題是如何使用prestashop cart與我的庫存數據庫進行交互?

是否有可能?什麼是最好的辦法呢?請幫助

+2

您可以創建一個腳本來導入您的產品/類別/客戶端到prestashop,您可以通過從ERP軟件創建一個csv文件來完成,也可以通過webservice進行導入,在這種情況下您應該使用xml文件 –

回答

0

您可以使用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(); 
    } 
} 

}

我希望這會幫助你。

相關問題