Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carsten Nørregaard Panek 28 posts 118 karma points
    Apr 01, 2016 @ 19:27
    Carsten Nørregaard Panek
    0

    Create variants programmicaly (Tea Commerce)

    Hi

    Can somebody please provide me with an example of how to add variants to the Teacommerce Variant Editor programmicaly?

    We have a setup where we create new product via the Umbraco ContentService, but we also need to add product variants programmicaly, how can we do that?

  • Anders Burla Johansen 2560 posts 8256 karma points
    Apr 04, 2016 @ 06:44
    Anders Burla Johansen
    0

    Hi Carsten

    The variants is just a normal Umbraco property editor. You can create a variant using Umbraco backoffice, go to the DB and see the JSON structure of the variant and then mimic that when you import. You still need to call SetStock for your products and variants.

    Kind regards

    Anders

  • Carsten Nørregaard Panek 28 posts 118 karma points
    Apr 04, 2016 @ 06:49
    Carsten Nørregaard Panek
    0

    Hi Anders

    So there is no official function to do this, I have to copy the behavior of Umbraco backoffice?

  • Anders Burla Johansen 2560 posts 8256 karma points
    Apr 04, 2016 @ 07:15
    Anders Burla Johansen
    0

    We have not made a function to import the variants as its just Umbraco JSON content. I can see it would be a bit easier to import using an API, but until that, you will have to use the Umbraco API and set content using the content service as you would normally do with properties.

  • Carsten Nørregaard Panek 28 posts 118 karma points
    Apr 05, 2016 @ 08:59
    Carsten Nørregaard Panek
    0

    Hi Anders

    I have a little trouble figuring out where the id property comes from - I mean, where does:

    "id": "1628e2d8-a159-6642-0d1e-af9a94a3ceae" "id": "fd4b6488-c32f-e5d9-3e37-af4ba0911768"

    in the below json come from? What does they refer to?

    { "variants": [ { "id": "1628e2d8-a159-6642-0d1e-af9a94a3ceae", "documentTypeAlias": "Variant", "validation": { "holesInVariants": false, "duplicatesFound": false }, "properties": { "stock": "", "productName": "", "sku": "", "priceDKK": "" }, "combination": [ { "name": "20", "id": 1086, "groupName": "Størrelse", "groupId": 1081 } ] }, { "id": "fd4b6488-c32f-e5d9-3e37-af4ba0911768", "documentTypeAlias": "Variant", "validation": { "holesInVariants": false, "duplicatesFound": false }, "properties": { "stock": "", "productName": "", "sku": "", "priceDKK": "" }, "combination": [ { "name": "22", "id": 1087, "groupName": "Størrelse", "groupId": 1081 } ] } ], "variantGroupsOpen": { "1081": true } }

  • Anders Burla Johansen 2560 posts 8256 karma points
    Apr 06, 2016 @ 07:33
    Anders Burla Johansen
    0

    Hi Carsten

    The id is just a guid generated by the java script that generates the variant combinations. So you can just generate some id's. The id is used when you add a variant to the cart.

    Hope you share the code that you are making - it might be great for others to see this as well :)

    Kind regards

    Anders

Please Sign in or register to post replies

Write your reply to:

Draft