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 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算