duanbi3385
2018-12-05 19:47
采纳率: 100%
浏览 48
已采纳

在prestashop上导入类别和产品

Currently I'm developing a php scipt to import and keep synced a prestashop database with data coming from a management software.

Is it a good method to insert data directly on the database or is it better to use the prestashop classes.

Can you give an exemplo how to import categories with class method ?

Kind regards

图片转代码服务由CSDN问答提供 功能建议

目前我正在开发一个php scipt进行导入,并使用来自管理软件的数据同步prestashop数据库。

将数据直接插入数据库是一种好方法,还是使用prestashop类更好。

您能举例说明如何使用类方法导入类别吗?

亲切的问候

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douyun3799 2018-12-06 13:23
    已采纳

    Try this :

    $category = new Category;
    $category->id = 155;
    $category->active = 0;
    $category->id_parent = 15;
    $category->name = "category";
    $category->link_rewrite = "one-category";
    //this will force ObjectModel to use your ID
    $_GET['forceIDs'] = true;
    $category->add();
    
    点赞 打赏 评论
  • dongnaizao8039 2018-12-07 07:58

    It's much reliable to use classes to reach your goal. Because you avoid all issues which can occur if versions of your prestashop instances will be different. With classes, you won't damage a database and won't confuse your data and also during the import, all data will be validated by classes. The example above seems to be correct and depends only on the number of fields that you want to import

    Copied above

    $category = new Category;
    $category->id = 155;
    $category->active = 0;
    $category->id_parent = 15;
    $category->name = "category";
    $category->link_rewrite = "one-category";
    //this will force ObjectModel to use your ID
    $_GET['forceIDs'] = true;
    $category->add();
    
    点赞 打赏 评论

相关推荐 更多相似问题