Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Andrei 68 posts 130 karma points
    Oct 19, 2010 @ 23:54
    Andrei
    0

    Importing product variants through the API

    Hi,

    We are importing products from an external source through the uCommerce API and I was wondering how do I create the variants. I am guessing that all there is to it is after creating the base product, I just create a second product representing the variant to which I set the ParentProductId to point the base product. And then I set properties like VariantSKU and variant properties (size-quantity). Would that be correct?

    Then I have another issue: some of these products don't have the size-quantity variant, so these properties should be go directly on the parent product. I'm not sure yet how to handle these, since in the backend UI I won't be able to see these properties on the parent product.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 20, 2010 @ 09:58
    Søren Spelling Lund
    0

    Hi Andrei,

    You're correct in your assumptions. Indeed the variant is just like a product with the only difference being that it's associated with a product family via parent product id.

    If you need some products where size is handled on the product itself and other where it's handled on the variant you'll need two product definitions. One for each type. If you make sure that you use the product definition particular to one or the other you'll be home free.

    Hope this helps.

  • Andrei 68 posts 130 karma points
    Oct 20, 2010 @ 14:31
    Andrei
    0

    Hi Søren,

    Thank you for your input, it helps.

    I have a new question related to importing products. For example when I import variants I think that is better for performance to just delete all previous variants and insert the new ones instead of trying to synchronize the new ones with existing ones which would involve iterating list too many times. However, when I try to delete a product variant I get an error because of the foreign key constraints, meaning that I have to first clear all related product data, like properties, product descriptions, etc.

    Is there some function in the API that deletes a product with all his related data? As I see it, the database should have cascade delete on product related tables, it makes no sense to delete a product and keep it's product description, prices and any other relations.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 20, 2010 @ 14:33
    Søren Spelling Lund
    0

    Product.DeepDelete() does exactly what you want.

  • Andrei 68 posts 130 karma points
    Oct 25, 2010 @ 23:27
    Andrei
    0

    Hi Søren,

    I have tried to save product properties for variant products. So I made the variant product, saved it and then tried to set it's properties as in the exemple here:

    http://blog.lasseeskildsen.net/post/uCommerce-How-To-Create-A-Product-Using-The-API.aspx,

    like:

    var property = product["MyProperty"];
    property.Value = "New value";
    property.Save();

    The values are not reflected in backend. In this link (http://www.publicvoid.dk/CatalogFoundationExplainedProductDefinitions.aspx) on the variants section I see variant properties appearing directly on the variants tab, but in my backend, the variant properties appear in the "Edit description" window of the variant. Then I saved some properties in backend and noticed that they are saved in the ProductDescriptionProperty table, not in ProductProperty. I have tried some combinations of setting the variant property (either on size, either on quantity, either on both), but with no luck. In this case the size is variant by quantity (different sizes have different stock quantity). What am I doing wrong?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 26, 2010 @ 09:05
    Søren Spelling Lund
    0

    Hi Andrei,

    You need a product definition to reflect the field before it can be displayed as part of the admin UI.

    For the example above you need to find the product definition for the product in question and add a field called MyProperty and assign the proper meta data such as "Is Variant Property" (if that's the case), "Render in Editor", "Multilingual" and so forth.

    You might find the article Catalog Foundation Explained: Product Definitions pertinent as well.

  • Andrei 68 posts 130 karma points
    Oct 26, 2010 @ 10:06
    Andrei
    0

    Hi Søren,

    That's what I'm saying, I have the product definition and variant properties, I even tried all combinations of variant fields (size variant, quantity variant or both as variants):

    but then on the product, under variant tabs I don't have the fields displayed as in the tutorial from your link:

    and when I use the sample code for importing products:

    var property = product["MyProperty"];
    property
    .Value = "New value";
    property
    .Save();

    the values are not reflected in the backend.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 26, 2010 @ 10:20
    Søren Spelling Lund
    0

    I get it now. It looks like you created you product definition with Multilingual enabled. Try removing that check mark on your field and you'll be good to go. Multilingual properties go into a separate data store to enable multiple versions of the same value.

  • Andrei 68 posts 130 karma points
    Oct 26, 2010 @ 10:48
    Andrei
    0

    Great, that did it. I tried all combination except removing the multilingual check.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 26, 2010 @ 10:50
    Søren Spelling Lund
    0

    Glad to help.

  • Andrei 68 posts 130 karma points
    Nov 05, 2010 @ 16:28
    Andrei
    0

    Hi Søren,

    I am importing around 4000 products (~400 + variants). This process takes around 30 mins in which time the cpu is 100%. For the import I am using V1 api, because the sample code (found here: http://blog.lasseeskildsen.net/post/uCommerce-How-To-Create-A-Product-Using-The-API.aspx) is using it. Should I try and use V2 for importing products, you think this would improve the speed?

    If yes, then I would appreciate some hints about how to make category relations, save properties and an equivalent for the product.DeepDelete() function. 

  • Daniel Howell 21 posts 42 karma points
    Dec 11, 2012 @ 07:28
    Daniel Howell
    0

    Hi Andrei (or Soren),

    Did you manage to find a way to DeepDelete() a product in V2? I am stuck with foreign key constraints that won't let me delete the product.

    Cheers,
    Daniel 

     

    Edit: actually - it looks like the default .Delete() method did it... just had 1 occurence of a foreign key constraint issue.

  • Søren Spelling Lund 1797 posts 2786 karma points
    Dec 17, 2012 @ 09:59
    Søren Spelling Lund
    0

    Hi Daniel,

    The default delete method works like the old DeepDelete method so it should work.

    Could you clarify whether you got a contraint issue or not using the default Delete method.

    Thanks.

     

Please Sign in or register to post replies

Write your reply to:

Draft