Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 3d095f6

Browse files
authored
Merge pull request #3111 from wordpress-mobile/issue/12971-product-global-unique-id-model
[Woo] Add the product global unique id property
2 parents d01056e + 7ca1276 commit 3d095f6

File tree

8 files changed

+18
-1
lines changed

8 files changed

+18
-1
lines changed

fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ open class WellSqlConfig : DefaultWellConfig {
4141
annotation class AddOn
4242

4343
override fun getDbVersion(): Int {
44-
return 205
44+
return 206
4545
}
4646

4747
override fun getDbName(): String {
@@ -2113,6 +2113,11 @@ open class WellSqlConfig : DefaultWellConfig {
21132113

21142114
db.execSQL("ALTER TABLE WCProductModel_temp RENAME TO WCProductModel")
21152115
}
2116+
2117+
205 -> migrateAddOn(ADDON_WOOCOMMERCE, version) {
2118+
db.execSQL("ALTER TABLE WCProductModel ADD GLOBAL_UNIQUE_ID TEXT")
2119+
db.execSQL("ALTER TABLE WCProductVariationModel ADD GLOBAL_UNIQUE_ID TEXT")
2120+
}
21162121
}
21172122
}
21182123
db.setTransactionSuccessful()

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/WCProductModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ data class WCProductModel(@PrimaryKey @Column private var id: Int = 0) : Identif
4444
@Column var description = ""
4545
@Column var shortDescription = ""
4646
@Column var sku = ""
47+
@Column var globalUniqueId = ""
4748

4849
@Column var price = ""
4950
@Column var regularPrice = ""

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/model/WCProductVariationModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ data class WCProductVariationModel(@PrimaryKey @Column private var id: Int = 0)
3434
@Column var description = ""
3535
@Column var permalink = ""
3636
@Column var sku = ""
37+
@Column var globalUniqueId = ""
3738
@Column var status = ""
3839

3940
@Column var price = ""

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductApiResponse.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ data class ProductApiResponse(
2525
val description: String? = null,
2626
val short_description: String? = null,
2727
val sku: String? = null,
28+
val global_unique_id: String? = null,
2829
val price: String? = null,
2930
val regular_price: String? = null,
3031
val sale_price: String? = null,

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductDtoMapper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ProductDtoMapper @Inject constructor(
4040
description = dto.description ?: ""
4141
shortDescription = dto.short_description ?: ""
4242
sku = dto.sku ?: ""
43+
globalUniqueId = dto.global_unique_id ?: ""
4344

4445
price = dto.price ?: ""
4546
regularPrice = dto.regular_price ?: ""

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductRestClient.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,9 @@ class ProductRestClient @Inject constructor(
18501850
if (storedWCProductModel.sku != updatedProductModel.sku) {
18511851
body["sku"] = updatedProductModel.sku
18521852
}
1853+
if (storedWCProductModel.globalUniqueId != updatedProductModel.globalUniqueId) {
1854+
body["global_unique_id"] = updatedProductModel.globalUniqueId
1855+
}
18531856
if (storedWCProductModel.status != updatedProductModel.status) {
18541857
body["status"] = updatedProductModel.status
18551858
}

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductVariationApiResponse.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ProductVariationApiResponse : Response {
1212
var description: String? = null
1313
var permalink: String? = null
1414
var sku: String? = null
15+
var global_unique_id: String? = null
1516
var status: String? = null
1617
var price: String? = null
1718
var regular_price: String? = null
@@ -75,6 +76,7 @@ class ProductVariationApiResponse : Response {
7576
status = response.status ?: ""
7677
description = response.description ?: ""
7778
sku = response.sku ?: ""
79+
globalUniqueId = response.global_unique_id ?: ""
7880

7981
price = response.price ?: ""
8082
regularPrice = response.regular_price ?: ""

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/ProductVariationMapper.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ object ProductVariationMapper {
3838
if (storedVariationModel.sku != updatedVariationModel.sku) {
3939
body["sku"] = updatedVariationModel.sku
4040
}
41+
if (storedVariationModel.globalUniqueId != updatedVariationModel.globalUniqueId) {
42+
body["global_unique_id"] = updatedVariationModel.globalUniqueId
43+
}
4144
if (storedVariationModel.status != updatedVariationModel.status) {
4245
body["status"] = updatedVariationModel.status
4346
}

0 commit comments

Comments
 (0)