Skip to content

Commit

Permalink
Merge pull request #3127 from wordpress-mobile/issue/13373-sort-varia…
Browse files Browse the repository at this point in the history
…tions-menu-order

[Woo POS][Non-Simple Products] Sort variations by menu_order
  • Loading branch information
samiuelson authored Jan 22, 2025
2 parents 657a72d + c7b933c commit 3061745
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,6 @@ class ProductRestClient @Inject constructor(
*
* @param [productId] Unique server id of the product
*
* Variations by default are sorted by `menu_order` with sorting order = desc.
* i.e. `orderby` = `menu_order` and `order` = `desc`
*
* We do not pass `orderby` field in the request here because the API does not support `orderby`
* with `menu_order` as value. But we still need to pass `order` field to the API request in order to
* preserve the sorting order when fetching multiple pages of variations.
*
*/
suspend fun fetchProductVariations(
site: SiteModel,
Expand All @@ -885,7 +878,7 @@ class ProductRestClient @Inject constructor(
"per_page" to pageSize.toString(),
"offset" to offset.toString(),
"order" to "asc",
"orderby" to "date"
"orderby" to "menu_order"
)

val response = wooNetwork.executeGetGsonRequest(
Expand Down Expand Up @@ -944,7 +937,7 @@ class ProductRestClient @Inject constructor(
): WooPayload<List<WCProductVariationModel>> {
val params = mutableMapOf(
"per_page" to pageSize.toString(),
"orderby" to "date",
"orderby" to "menu_order",
"order" to "asc",
"offset" to offset.toString()
).putIfNotEmpty("search" to searchQuery)
Expand Down

0 comments on commit 3061745

Please sign in to comment.