CatalogItemVariation order in UPSERT and RETRIEVE queries

Good morning Square,

Suppose that we perform a call to the Upsert Catalog Object endpoint to upload a CatalogItem to which we have attached some variations. We can do this without using the batch endpoint, simply by using the variations setter of CatalogItem class to input a list of variations. It is, of course, our job to properly connect the variations with the original item through the itemId() setter in CatalogItemVariation class.

My application works by only talking to the CatalogItem to which those variations are registered. It does not store any CatalogItemVariation IDs, merely because with the ID of the CatalogItem at the top level I can pull everything I need. If I need to access variation data, I do so by the top - level CatalogObject that a retrieval query for that item will give me.

My question is: are there any guarantees that those variations will stay in that list in exactly the order in which they were uploaded? I have different names for those variations, and I wanted to write some tests to ensure Iā€™m getting the right names back, but it would make the test more efficient to run if I could make that assumption.

Regards,

JF

If the variations are on an item then they should stay in the same order, unless the ordinals are changed for the variations (which can be done via API or dashboard).

1 Like