Announcement

Collapse
No announcement yet.

Miva JSON API CategoryProduct_Update_Assigned Multiple Categories at Once

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Miva JSON API CategoryProduct_Update_Assigned Multiple Categories at Once

    Perhaps I am missing something, but are we able to assign multiple categories to a product via the API?
    I figured that in the API request one could list an array of category codes to assign to, but I get hit with an error

    REQUEST:
    HTML Code:
    Array
    (
      [Store_Code] => STORE_CODE
      [Function] => CategoryProduct_Update_Assigned
      [Miva_Request_Timestamp] => 8675309
      [Category_Code] => Array
      (
        [0] => cat-01
        [1] => cat-02
      )
      [Product_Code] => PROD
      [Assigned] => 1
    )
    RESPONSE:
    HTML Code:
    {
      "success": 0,
      "error_code": "MER-JSN-CAT-00032",
      "error_message": "Category not found"
    }
    Is there a way to assign multiples or would a separate API request need to be made for every category?

    ALSO
    Am I understanding correctly that this is the only function that can assign a product to a category? I couldn't add categories to a product during a Product_Insert or a Product_Update correct?
    Benjamin Smith - Developer
    www.midwestgunworks.com

    #2
    That function operates on a single product to assign it to a single category. You can do multiple assignments in a single API call using the multi-call format:

    https://docs.miva.com/json-api/multicall


    And that is the only way to assign products to categories, You cannot do it as part of the product insert/update calls.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Oh wow, thanks Brennan !!

      I had not come across this feature of the API but it sure seems legit! This will make my calls play so much better and keep them organized rather than throwing several calls for each item in a loop.
      Benjamin Smith - Developer
      www.midwestgunworks.com

      Comment


        #4
        Brennan , on the Multi Call, if I am inserting a product, would I not be able to utilize ProductImage_Add since it requires the Product_ID?

        Would I have to have two additional calls to apply image changes, one to request prod info from Miva (to get the created Product_ID) and then another to use that ID and assign the images proper?
        Benjamin Smith - Developer
        www.midwestgunworks.com

        Comment


          #5
          Yes it would need to be:

          1. Insert New Product
          2. Query Product Id
          3. Add Images

          However, in the next release of Miva, all insert operations via the JSON API will return the id of the recored inserted so you'll be able to remove step 2 above. But until them it will require you to get it in a separate API call.
          Brennan Heyde
          VP Product
          Miva, Inc.
          [email protected]
          https://www.miva.com

          Comment


            #6
            Much appreciated! That sounds like a good update to the API, but yes, for now I'll be rolling that extra step.
            Benjamin Smith - Developer
            www.midwestgunworks.com

            Comment

            Working...
            X