Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFC Product Import is not updating images #13149

Open
mkllnk opened this issue Feb 13, 2025 · 0 comments · May be fixed by #13153
Open

DFC Product Import is not updating images #13149

mkllnk opened this issue Feb 13, 2025 · 0 comments · May be fixed by #13153
Assignees

Comments

@mkllnk
Copy link
Member

mkllnk commented Feb 13, 2025

Description

When updating products by importing a DFC catalog we never update the image. And we shouldn't update it unless it has changed.

How do we know if it changed or not?

To be completely sure, we would need to download the current image and the given image and compare them. But storing the new image takes just as long.

Most product images are uploaded by users and each version has its own unique id and URL. That is true for OFN and Shopify (our only other known integration at the moment). So if we remember the URL of the image then we can compare that.

What if my other platform keeps the same product image? In that case the referenced image URL needs to contain a version number, hash or timestamp. That can be a query parameter or even a hash anchor. For example:

https://example.net/product5/image.png#hash:abc123

Implementation

ActiveStorage supports metadata.

blob.custom_metadata[:origin] = semantic_id

Then later we can check before assigning:

    image = supplied_product.isVariantOf.first.try(:image) ||
            supplied_product.image

    return if image.blank?
    return if image == spree_product.image.attachment.blob.custom_metadata[:origin]

    spree_product.image = ImageBuilder.import(image)
@github-project-automation github-project-automation bot moved this to All the things 💤 in OFN Delivery board Feb 13, 2025
@mkllnk mkllnk changed the title DFC Product Import is importing the same images repeatedly DFC Product Import is not updating images Feb 13, 2025
@mkllnk mkllnk self-assigned this Feb 13, 2025
@mkllnk mkllnk moved this from All the things 💤 to In Progress ⚙ in OFN Delivery board Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress ⚙
Development

Successfully merging a pull request may close this issue.

1 participant