|
@@ -29,14 +29,14 @@ var (
|
|
|
"any(inventory_item.tracked) as tracked",
|
|
|
"any(inventory_level.available) as available",
|
|
|
"if(tracked, if(available > 0, true, if(inventory_policy == 'continue', true, false)), true) as for_sale",
|
|
|
- fmt.Sprintf("min(product_variant.price['%s']) as price_min", currency),
|
|
|
- fmt.Sprintf("max(product_variant.price['%s']) as price_max", currency),
|
|
|
- fmt.Sprintf("min(product_variant.compare_at_price['%s']) as compare_at_price_min", currency),
|
|
|
- fmt.Sprintf("max(product_variant.compare_at_price['%s']) as compare_at_price_max", currency),
|
|
|
"any(created_at) as created_at", "any(updated_at) as updated_at", "any(published_at) as published_at", "any(deleted_at) as deleted_at",
|
|
|
},
|
|
|
ln.SqlFieldSelection("title", "", "any"),
|
|
|
ln.SqlFieldSelection("description", "", "any"),
|
|
|
+ fmt.Sprintf("min(product_variant.price['%s']) as price_min", currency),
|
|
|
+ fmt.Sprintf("max(product_variant.price['%s']) as price_max", currency),
|
|
|
+ fmt.Sprintf("min(product_variant.compare_at_price['%s']) as compare_at_price_min", currency),
|
|
|
+ fmt.Sprintf("max(product_variant.compare_at_price['%s']) as compare_at_price_max", currency),
|
|
|
)
|
|
|
}
|
|
|
productCollectionSelection = func(ln model.LanguageCode) []string {
|
|
@@ -62,12 +62,51 @@ var (
|
|
|
ln.SqlArraySelection("values"),
|
|
|
)
|
|
|
}
|
|
|
+ productOptionSelectedSelection = func(ln model.LanguageCode) []string {
|
|
|
+ return append([]string{
|
|
|
+ "id",
|
|
|
+ "if(notEmpty(value_ln), value_ln, value_en) as value",
|
|
|
+ "position", "created_at", "updated_at", "published_at", "deleted_at",
|
|
|
+ },
|
|
|
+ ln.SqlFieldSelection("name", "", ""),
|
|
|
+ fmt.Sprintf("arrayElement(values, tupleElement(opt, 2))['%s'] as value_en", model.LanguageCodeEn),
|
|
|
+ fmt.Sprintf("arrayElement(values, tupleElement(opt, 2))['%s'] as value_ln", ln),
|
|
|
+ )
|
|
|
+ }
|
|
|
productOptionKey = func(clause string, args ...any) *cache.SqlKey {
|
|
|
return cache.NewSQLKey(
|
|
|
"product_option",
|
|
|
time.Minute,
|
|
|
clause, args...)
|
|
|
}
|
|
|
+ productVariantSelection = func(ln model.LanguageCode, currency generated.CurrencyCode) []string {
|
|
|
+ return append([]string{
|
|
|
+ "any(t.id) as id",
|
|
|
+ "any(t.product_id) as product_id",
|
|
|
+ "any(t.inventory_item_id) as inventory_item_id",
|
|
|
+ "any(t.position) as position",
|
|
|
+ "any(t.image) as image",
|
|
|
+ "any(t.inventory_management) as inventory_management",
|
|
|
+ "any(t.inventory_policy) as inventory_policy",
|
|
|
+ "any(t.grams) as grams",
|
|
|
+ "any(t.weight) as weight",
|
|
|
+ "any(t.weight_unit) as weight_unit",
|
|
|
+ "any(t.created_at) as created_at",
|
|
|
+ "any(t.updated_at) as updated_at",
|
|
|
+ "any(t.published_at) as published_at",
|
|
|
+ "any(t.deleted_at) as deleted_at",
|
|
|
+ "sum(inventory_level.available) as available",
|
|
|
+ "any(inventory_item.sku) as sku",
|
|
|
+ "any(inventory_item.barcode) as barcode",
|
|
|
+ "any(inventory_item.requires_shipping) as requires_shipping",
|
|
|
+ "any(inventory_item.tracked) as tracked",
|
|
|
+ "if(tracked, if(available > 0, true, if(inventory_policy == 'continue', true, false)), true) as for_sale",
|
|
|
+ },
|
|
|
+ ln.SqlFieldSelection("title", "product", "any"),
|
|
|
+ fmt.Sprintf("any(t.price['%s']) as price", currency),
|
|
|
+ fmt.Sprintf("any(t.compare_at_price['%s']) as compare_at_price", currency),
|
|
|
+ )
|
|
|
+ }
|
|
|
productVariantKey = func(clause string, args ...any) *cache.SqlKey {
|
|
|
return cache.NewSQLKey(
|
|
|
"product_variant",
|