Solved

BUG: Duplicated Product Metafields in Random Order

Jason27
Shopify Partner
107 3 38

When duplicating a product, the metafields are copied over but in a random order. Why not keep them in the same order (ie. id / created_at)? 

 

I rely on a specific order of the metafields, why re-create them randomly? Wheres the sense in that.

 

Accepted Solution (1)
cemgurbey
Shopify Staff (Retired)
3 2 2

This is an accepted solution.

Thanks for the feedback @Jason27. Currently, the system does not guarantee the order of metafields when duplicating a product. I’ve passed your feedback along to the appropriate team, but in the meantime, you may need to adapt your code accordingly.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

cemgurbey
Shopify Staff (Retired)
3 2 2

Hello @Jason27, thank you for bringing this. Could you provide more context on your use case?

To learn more visit the Shopify Help Center or the Community Blog.

Jason27
Shopify Partner
107 3 38

Hi @cemgurbey We use the metafields to store snapshots. We store the 1st snapshot, and the last 2 snapshots, for logging, restoring, and updating. When a product is duplicated, the snapshots go out of order (logically they should be copied over in order based on id or created_at ASC). And the snapshots are useful for the duplicated product, because they contain links to original photos. We can then go back and grab those original photos and set them up for the duplicated product. Getting the original photos for the last snapshot is important since they may be different than the 1st snapshot.

 

Also as a somewhat separate issue, when you duplicate a product that has WEBP photos, based on the tests I ran, they are converted to PNG photos, which doesn't seem logical. I created workarounds for both these issues, but I had to really debug the api to understand that it doesn't quite work as logically expected. Cheers

cemgurbey
Shopify Staff (Retired)
3 2 2

This is an accepted solution.

Thanks for the feedback @Jason27. Currently, the system does not guarantee the order of metafields when duplicating a product. I’ve passed your feedback along to the appropriate team, but in the meantime, you may need to adapt your code accordingly.

To learn more visit the Shopify Help Center or the Community Blog.