Menu Close
    Hire us Request quote Reading list Switch to dark mode
    lockdownWebkulUp

    Understanding Child product and its function in Virtuemart

    We know in Virtuemart we can make child product leaving some of its parameters that will be taken from parent product. We can understand this with an example like:

    First we create one Parent product with name Parent and its two child products Child1 and Child2

    Now we set some basic attributes of them:

    Parent => Price = $100, Manufacturer = ‘xyz’.
    Child1 => Price = not set, Manufacturer = not set
    Child2 => 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:

    To use the listed function we must have included vmconfig.php and initialized its loadConfig() method, as


    then call respective methods after taking instance of product model as

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .


    now you can simple call any of the method as

    getproduct() will return data with attributes of parent product, while
    getproductSingle() will not only return data for a single product but it contains the attribute of the same product regardless of it being a child or a parent.

    So, from the above cases

    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 differences in return parameters of both of these functions, as you get basePrice and salesPrice using getProduct() but have to evaluate final price if you use getProductSingle()

    For any query regarding virtuemart plugins and add-ons you can communicate with us by creating a ticket at:
    https://webkul.uvdesk.com/en/customer/create-ticket/

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close