datafoodconsortium / connector-typescript

The connector makes things easier when integrating with DFC. This is the TypeScript version.
MIT License
2 stars 1 forks source link

Option to add/retrieve image related data fields? #3

Closed dupreesi closed 7 months ago

dupreesi commented 7 months ago

Hey, I'm currently facing an issue that the connector cannot yet seem to handle image related data. We're using the connector in order to export and import product data between Shopify shops. Shopify expects us to provide the following parameters so that we can create Products and their Variants and render them including images:

{
"id": 35456987955371,
"alt": "Camelina Seed (ToL) - Hodmedod's British Pulses & Grains",
"position": 1,
"product_id": 7861854306475,
"width": 1800,
"height": 1200,
"src": "https://cdn.shopify.com/s/files/1/0639/2866/4235/products/NGCS-Camelina-Seed_6fd304c5-5c4f-46ef-96e9-208d989fadf3.jpg?v=1705924554",
"variant_ids": []
}

To note: a Shopify product instance could have multiple images. Wondering if their is a way for us to 1) Add image data to a SuppliedProduct (at least I think we'd need id, src, productId, alt) 2) Retrieve these fields (I can see that there is a getImage() method as part of Exhibitable which doesn't seem to be linked to the SuppliedProduct class)

Thanks for your great work :)

lecoqlibre commented 7 months ago

Hi @dupreesi, thank you for your feedback!

Indeed, image(s) for products is not supported yet. Do you have a particular deadline regarding this issue?

Currently the DFC model supports image only as an URL (which could be used to populate the src attribute). But I suppose this will not be enough for you as you are mentioning dimensions and others, right? We have an ongoing discussion about how to support image attributes here: https://github.com/datafoodconsortium/ontology/discussions/77.

What does the product_id refers to? We have a SKU attribute that could perhaps hold this information.

What does the id refers to?

RaggedStaff commented 7 months ago

Hi @lecoqlibre Just wanting to clarify - we could probably work with being able to embed the image URL within suppliedProduct.

Does the typescript Connector currently support that?

@dupreesi - we'd potentially need to download the image to store in Shopify & assign some values to the extra fields (can we derive dimensions from the image, & add alt text from product name) ?

RaggedStaff commented 7 months ago

@lecoqlibre

The blocker here is the inability to retrieve the exported suppliedProduct:image:url.

We can live without the wider Image object for now. How quickly can you include this field in the typescript Import functionality ?

lecoqlibre commented 7 months ago

I just pushed a new version alpha.8 on npm which support product images (commit).

Can you try it @dupreesi?

Example:

const suppliedProduct = connector.createSuppliedProduct({
    semanticId: "http://myplatform.com/tomato",
    description: "Awesome tomato",
    images: ["http://example.org/image1", "http://example.org/image2"]
});

suppliedProduct.addImage("http://example.org/image3");

suppliedProduct.getImages(); // will return ["http://example.org/image1", "http://example.org/image2", "http://example.org/image3"]
dupreesi commented 7 months ago

Hi @lecoqlibre, amazing thanks for the swift updates! I will try and let you know how it went!

dupreesi commented 7 months ago

It works like a charm @lecoqlibre

RaggedStaff commented 7 months ago

I think this seems resolved, so closing.