duanliangman5398 2014-06-04 08:59
浏览 35
已采纳

Virtuemart 2产品型号类中getProductSingle()和getProduct()之间有什么区别?

In VirtueMartModelProduct class there are two methods to get a product object from the database: getProductSingle() and getProduct(). I'm a bit confused with the code below each method, so I would like to know what's the difference between them and when I have to use getProductSingle instead of getProduct.

The VirtueMartModelProduct class is at: administrator\components\com_virtuemart\models\product.php

  • 写回答

2条回答 默认 最新

  • doulangxun7769 2016-02-05 08:24
    关注

    I know its a bit late, but you can understand it with this. As the documentation of Virtuemart says

    getProduct() function creates a product with the attributes of the parent.

    We know in Virtuemart we can make child products leaving some of its parameters that will be taken from parent product. So we set product

    Parent Price = $100, Manufacturer = 'xyz'.

    Now if two child products are created like:

    Child1 is created with blank Price and Manufacturer

    Child2 is created with its own values Price = $250, Manufacturer = 'abc'.

    The buyer will finally get to see:

    Child1 Price = $100, Manufacturer = 'xyz', taken from its parent.

    Child2 Price = $250, Manufacturer = 'abc'.

    Use of functions and return data:

    for Child1: getProductSingle(), returns Manufacturer = '', on the same hand getProduct(), returns Manufacturer = 'xyz'.

    for Child2: both getProductSingle() and getProduct() returns Manufacturer = 'abc' as it is directly set onto that product.

    There are other difference in parameters, as you get salesPrice using getProduct() but have to calculate final price if you use getProductSingle()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题