Can I get "custom" field via API

anhdinh89anhdinh89 Member Posts: 10
Hi all

Could someone help me get data of custom field on the product via API?

for example : https://www.schnibbe-kaffee.de/de/kapverdischen-inseln.html

I can see list of custom field of this product





Is there the way to me get it from lightspeed API 

I have tried get by 

https://api.webshopapp.com/{{lang}}/catalog/69778499.json
https://api.webshopapp.com/{{lang}}/products/69778499.json

But there are no custom field on response

Could someone help me?

Thanks

12 comments

  • gregaricangregarican Member Posts: 333 
    edited September 2018
    if the eCom API is similar to the Retail API, then you should be able to load_relations. Similar to this, again from the Retail API and not the eCom API.

    In this case below, I am pulling shop allocations, custom fields, images, and tags. Of course the responsiveness will exponentially decrease as you pull more relations. At least that's our experience in the Retail API.

    https://api.merchantos.com/API/Account/{AccountId}/Item/{ItemId}.json?load_relations=["CustomFieldValues", "CustomFieldValues.value","ItemShops", "Images", "TagRelations.Tag"]

    Looking at the eCom product API endpoint documentation (https://developers.lightspeedhq.com/ecom/endpoints/product/) I don't see the load_relations mechanism, however. :neutral:
    Post edited by gregarican on
  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 572 moderator
    Hey @anhdinh89, you can access the custom fields of a particular product via the Catalog API which essentially gives you all the data about a product.

    You can be read more about this here:
    https://developers.lightspeedhq.com/ecom/endpoints/catalog/#get-retrieve-an-item

    The data object for this is nested one level deep at {{Product.fields}}

    A standard request for such a query would look like:

    https://{{cluster}}/{{language}}/catalog/{{productId}.json

    Hope this helps!

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • anhdinh89anhdinh89 Member Posts: 10
    Hi all,

    Thank lot of your response, it  save my day but I found an issue  with the product were copied(duplicate), the custom fields don't return via API

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 572 moderator
    Hey @anhdinh89 could clarify what you mean by duplicate products and which endpoints you're not able to receive custom fields through?

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • gregaricangregarican Member Posts: 333 
    edited October 2018
    I think I see what he's talking about. If you click the 'Duplicate' button in the web client, the copied product's custom fields aren't pushed over into the newly-created product. I just tested this now. Attaching an example set.

    As a matter of fact other key elements aren't copied over either. Including the images. Figure if you're duplicating a product it'd be logical that you'd look for the images to copy over as well. Saves quite a bit of manual work. 

    What all fields do copy over? E.g. - description, cost, price, brand, vendor, etc.?
  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 572 moderator
    edited October 2018
    Hey @gregarican @anhdinh89 good question!

    I've tested and it looks like: 

    The SKUs, stock, average cost , Item and Sales history details and custom fields don’t copy over, the rest does as expected.

    If you're looking to duplicate a product it's probably more efficient to duplicate it via the API in an automated script

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • gregaricangregarican Member Posts: 333 
    Thanks for the confirmation! Shouldn't this be passed along as a defect? If the Duplicate button really doesn't push much more over than a couple of fields it's a bit dubious in the LS Retail web client. Optimally it should truly duplicate everything but item history, correct?
  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 572 moderator
    @gregarican when I think about it logically the design of this is pretty sound. 
    SKUs are unique for a given product and would be strange to push other by design

    Average cost is based upon sales history and thus won't and shouldn't be pushed over. 

    Transfer status and and Sales History again logically shouldn't be copied since that will mutate the cost and sales values in your reports.

    Regarding the last, product team made a decision not to push into Custom Fields. Their use is very limited outside of API integrations and serves little purpose beside that unless using it for manual look ups and entries in the UI.
     
    If you and others believe that this should be re-explored, I would suggest you log onto to our ideas page to give this point a voice: 

    https://my.lightspeedpos.com/CustomerPortal_Ideas

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • JoeyJoey Administrator, Moderator, Lightspeed Staff Posts: 197 moderator
    Just to chime in about @anhdinh89's original question, which is not related to Retail.
    Duplicating a product within eCom will also copy over the custom field(s) and its values. The custom fields (when a product is duplicated) are also accessible from the API when I test this.
    eCom Support Team
    Lightspeed HQ
  • gregaricangregarican Member Posts: 333 
    @Adrian Samuel, while I understand individual items can carry some unique characteristics (e.g. - different landed cost, serialized identifiers, obviously item history), elements such as UPC, EAN, Manufacturer SKU, images, custom fields, categories, product tags, MSRP, etc. should default to the same.

    After all, from the front-end user perspective, it's quicker to change just an uniquely-defined element or two compared to going into all of these other fields from scratch and defining them. A basic case in point is the image array. A duplicate item should have duplicate images without fail, right?

    This observation is based on working with and implementing numerous POS/Inventory systems going back a-ways. But the issue doesn't affect us internally here with our Store5a company, since they carry pre-owned one of a kind items. Our other companies carry more cookie cutter fashion/designer items which would be affected. But we aren't putting them on LS Retail at this time yet.

    And I realize a lot of gaps can be addressed via the API and custom development. But as the gap list grows it begs the question about LS Retail being an ideal solution for outliers. :neutral:
  • anhdinh89anhdinh89 Member Posts: 10
    Hi @Joy

    I used https://api.webshopapp.com/de/catalog/69778499.json

    to get custom field(s)  for this product 

    this is response from api
     "fields": {
                "4158455": {
                    "id": 4158455,
                    "sortOrder": 1,
                    "isRequired": true,
                    "maxCharacters": false,
                    "type": "radio",
                    "title": "Mahlgrad",
                    "values": []
                }
            }

    after that double check 
    https://www.schnibbe-kaffee.de/de/kapverdischen-inseln.html?format=json



    you can see that there are no custom field(s) in API's response  while it appear on the website

    Thanks
  • Alex LugoAlex Lugo Administrator, Lightspeed Staff Posts: 155 moderator
    Hello @anhdinh89,

    This is a known issue, copying a product will not copy its custom fields. Our Dev team is working to resolve this issue.

    We will let you know as soon as we determine the cause and fix it. Thank you and sorry for the inconveniences this may be causing.
    Alex Lugo
    API Support Specialist
    Lightspeed HQ
Sign In or Register to comment.