2015-06-02 17:26
浏览 22


I have to update the price and quantity values of specific products in a database.

As I understand, simply executing sql commands is not a great option since there are a lot of tables which have similar informations. I have read that Product() object should be created.

How should I create the Product object and then update it in the database?

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

我必须更新 price quantity 值 数据库中的特定产品

据我所知,简单地执行sql命令不是一个很好的选择,因为有很多表具有相似的信息。 我已经读过应该创建 Product()对象。

我应该如何创建 Product 对象,然后在 数据库?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyou2635 2015-06-02 20:13

    You can check the class ProductCore in classes/Product.php for various methods and properties

    Generally, you would write some code like this

    //assuming you have the product id as $id_product
    $product = new Product($id_product);
    //change the product properties
    $product->quantity = 10;
    $product->price = 60.2;
    //save the changes

    Edit: To update the quantity you can use this method:

    StockAvailable::updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null);
    解决 无用
    打赏 举报

相关推荐 更多相似问题