Skip to content

Commit

Permalink
Add model for global unique id in products and variations
Browse files Browse the repository at this point in the history
  • Loading branch information
toupper committed Nov 21, 2024
1 parent 3b731c3 commit c813474
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ open class WellSqlConfig : DefaultWellConfig {
annotation class AddOn

override fun getDbVersion(): Int {
return 205
return 206
}

override fun getDbName(): String {
Expand Down Expand Up @@ -2113,6 +2113,11 @@ open class WellSqlConfig : DefaultWellConfig {

db.execSQL("ALTER TABLE WCProductModel_temp RENAME TO WCProductModel")
}

205 -> migrateAddOn(ADDON_WOOCOMMERCE, version) {
db.execSQL("ALTER TABLE WCProductModel ADD GLOBAL_UNIQUE_ID STRING")
db.execSQL("ALTER TABLE WCProductVariationModel ADD GLOBAL_UNIQUE_ID STRING")
}
}
}
db.setTransactionSuccessful()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ data class WCProductModel(@PrimaryKey @Column private var id: Int = 0) : Identif
@Column var description = ""
@Column var shortDescription = ""
@Column var sku = ""
@Column var globalUniqueId = ""

@Column var price = ""
@Column var regularPrice = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ data class WCProductVariationModel(@PrimaryKey @Column private var id: Int = 0)
@Column var description = ""
@Column var permalink = ""
@Column var sku = ""
@Column var globalUniqueId = ""
@Column var status = ""

@Column var price = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class ProductApiResponse(
val description: String? = null,
val short_description: String? = null,
val sku: String? = null,
val globalUniqueId: String? = null,
val price: String? = null,
val regular_price: String? = null,
val sale_price: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ProductDtoMapper @Inject constructor(
description = dto.description ?: ""
shortDescription = dto.short_description ?: ""
sku = dto.sku ?: ""
globalUniqueId = dto.globalUniqueId ?: ""

price = dto.price ?: ""
regularPrice = dto.regular_price ?: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,9 @@ class ProductRestClient @Inject constructor(
if (storedWCProductModel.sku != updatedProductModel.sku) {
body["sku"] = updatedProductModel.sku
}
if (storedWCProductModel.globalUniqueId != updatedProductModel.globalUniqueId) {
body["global_unique_id"] = updatedProductModel.globalUniqueId
}
if (storedWCProductModel.status != updatedProductModel.status) {
body["status"] = updatedProductModel.status
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ProductVariationApiResponse : Response {
var description: String? = null
var permalink: String? = null
var sku: String? = null
var globalUniqueId: String? = null
var status: String? = null
var price: String? = null
var regular_price: String? = null
Expand Down Expand Up @@ -75,6 +76,7 @@ class ProductVariationApiResponse : Response {
status = response.status ?: ""
description = response.description ?: ""
sku = response.sku ?: ""
globalUniqueId = response.globalUniqueId ?: ""

price = response.price ?: ""
regularPrice = response.regular_price ?: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ object ProductVariationMapper {
if (storedVariationModel.sku != updatedVariationModel.sku) {
body["sku"] = updatedVariationModel.sku
}
if (storedVariationModel.globalUniqueId != storedVariationModel.globalUniqueId) {
body["global_unique_id"] = updatedVariationModel.globalUniqueId
}
if (storedVariationModel.status != updatedVariationModel.status) {
body["status"] = updatedVariationModel.status
}
Expand Down

0 comments on commit c813474

Please sign in to comment.