Create ProductAttribute

basterbruggebasterbrugge Member Posts: 11

Hi,

I am trying to add product attributes to a product via the API. First, I PUT the type on the product itself and after that I want to add ProductAttribute. However, there only seems to be a PUT for /product/<_product_id>/attributes/<product_attribute_id>.json, but not a POST for /product/<product_id>/attributes.json.

Am I missing something?

Rgds,

Bas

10 comments

  • gregaricangregarican Member Posts: 510 

    Based on the API docs (https://developers.lightspeedhq.com/ecom/endpoints/productattribute/#put-update-a-product-attribute) it appears as if the product attributes need to be pre-defined using the web UI. When these are defined, then based on one of their product attribute ID then you can assign the value of one for a specific product. Make sense?

    For example, if there is an existing product attribute entitled "Made In" that was created in the ecom web UI then based on its ID you can then assign a value of "Canada" for a specific product using the logic above...

  • basterbruggebasterbrugge Member Posts: 11

    So I cannot assign a type to a product via the API and fill the attributes afterwards? It always has to be done via the Web UI? That makes it useless when integrating an ERP (or product management) system with Lightspeed, since the goal is the create and manage products in the ERP and synchronise them to Lightspeed.

  • gregaricangregarican Member Posts: 510 

    I am not 100% sure, but based on the API documentation this seems to be the case. I would defer to any Lightspeed staffers who could speak to this. @LucienVersendaal , I've seen you reply on here recently to a few threads, can you shed any light on my assumptions?

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 345 moderator
    edited July 8

    Hi guys,

    First you'll need to create a Type after that you can create the Attribute. Now you bring these two together with TypesAttribute. In the docs you'll see the payload. After that you'll need to update to product with the type

  • basterbruggebasterbrugge Member Posts: 11

    @LucienVersendaal That is what I do, but after assigning the type to the product, I cannot add the attribute values to that specific product.

    When calling the url below, it returns an empty array.

    products/%s/attributes.json
    


  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 345 moderator

    Hi @basterbrugge,

    Unfortunately we found this bug yesterday with testing this out. We've logged this in our system, so it's up to our devs to give a prio on this and fix it. I will create a ticket for you and attach the issue, so if there are any updates on this you'll get a message.

    Sorry for this inconvenience.

  • basterbruggebasterbrugge Member Posts: 11

    @LucienVersendaal Do you have any updates on this? Our customers are really eager to use our ERP integration including this feature.

    Thx,

    Bas

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 345 moderator

    Hi @basterbrugge,

    I was checking again on this issue, but it seems to work. When I use this endpoint:

    PUT /products/{product_id}/attributes/{product_attribute_id}.json
    

    With the following payload it will update the value of the attribute:

    {
        "productAttribute" :
        {
            "value" : "Fill in the value"
        }
    }
    

    Can you tell me in which shop you're testing this, so I can check with you?

  • basterbruggebasterbrugge Member Posts: 11
    edited September 7

    @LucienVersendaal I know, but to able to call the PUT we need a product_attribute_id. And the product attributes are not created when assigning a type to a product via the API (they are when assign a type to a product via de UI).

    I am testing in shop https://afas-test.webshopapp.com/ (shop id: 265364)

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 345 moderator

    Hi @basterbrugge,

    Okay thanks I see. I will create a ticket for you so you can get track on this. Our devs need to prioritize this case, when I got any updates I will let you know immediately. Sorry this inconvenience.

    Thank you for your patience.

Sign In or Register to comment.