Results 1 to 3 of 3

Thread: Dealing with variants in Orders and Product databases

  1. #1
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Dealing with variants in Orders and Product databases

    I have two scenarios where I need to understand how variants can be easily brought in:

    1) When a customer places an order and the order is paid, I have a HOOK that renders a Voucher for each item in the order. However now that the customer has added variants, it no longer works. How do I deal with obtaining the Product items contain variant information? The method $objOrder->getProducts() isn't working correctly.

    At the moment the Single Product works perfectly, but as soon as one of the order items is a variant, it somehow tosses the product teaser, which is required. Also, how to I know it's a variant and how do I access each variation. I know a bit of coding, but this is way beyond me.

    Please help.


    2) I wrote an export of Product DB for the client. Now they need to include variants as well, somehow. Same problem as above, just on a different place.

    Anyone?

  2. #2
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Re: Dealing with variants in Orders and Product databases

    Hi,

    variants are stored in the tl_iso_products table like any other product, the difference is that they don't have any information except the information that is different from the 'main' product.

    This means the variants don't have titles, teasers, alias' etc. They only have attributes like size, colour and price.

    So if you fetch a variant by it's ID you don't get a teaser. Instead you need to use the variant's PID to get the teaser from the 'main' product.

    To get all the variants for a product you need to do something like this:
    Code:
    SELECT * FROM tl_iso_products WHERE pid = {ID OF THE PRODUCT}
    You can tell which products are variants and which aren't by checking their PID. If the PID is 0 then they are main products, if the PID is anything other than 0 then they're variants.

    You can tell which main products have variants by doing a count of how many records exists with a PID that matches the product's ID. If it's more than one then the product has variants.

    Hopefully that helps!

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Dealing with variants in Orders and Product databases

    Why does the IsotopeProductCollection function getProducts() not work then? It's supposed to do all the work for me, it only returns the details of the variant product. I hope I'll be able to figure this out, because I've spent so much time on custom coding on Isotope, that I've decided to give up on Contao and Isotope and completely move away form it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •