如何从外部数据库更新prestashop产品详细信息?

如何从外部数据库更新prestashop产品详细信息?,prestashop,prestashop-1.6,prestashop-1.5,Prestashop,Prestashop 1.6,Prestashop 1.5,我有一家杂货店,我想在网上卖这个产品。所以我用了一个叫做“prestashop”的CMS购物车 即使我已经安装并开始工作,但我有一些问题 我有自己的库存数据库来存储所有产品详细信息。有了一个UI,我可以将产品详细信息添加到数据库(数量、价格等)。现在我的问题是如何使用prestashop购物车与我的库存数据库交互 可能吗?最好的方法是什么?请提供帮助您可以使用prestashop站点中的脚本从外部数据库添加类别。为此,使用frontcontroller创建一个模块(用于cron作业或运行脚本),

我有一家杂货店,我想在网上卖这个产品。所以我用了一个叫做“prestashop”的CMS购物车

即使我已经安装并开始工作,但我有一些问题

  • 我有自己的库存数据库来存储所有产品详细信息。有了一个UI,我可以将产品详细信息添加到数据库(数量、价格等)。现在我的问题是如何使用prestashop购物车与我的库存数据库交互

  • 可能吗?最好的方法是什么?请提供帮助

    您可以使用prestashop站点中的脚本从外部数据库添加类别。为此,使用frontcontroller创建一个模块(用于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文件