product variants table split off from category variants table, variant values table updated to reflect

This commit is contained in:
2025-10-03 02:16:24 -07:00
parent d49a8784e6
commit 49912abd3a
21 changed files with 477 additions and 46 deletions

View File

@@ -56,9 +56,9 @@ class ProductSkuVariantValuesTable extends Table
'foreignKey' => 'product_sku_id',
'joinType' => 'INNER',
]);
$this->belongsTo('ProductCategoryVariants', [
'className' => 'CakeProducts.ProductCategoryVariants',
'foreignKey' => 'product_category_variant_id',
$this->belongsTo('ProductVariants', [
'className' => 'CakeProducts.ProductVariants',
'foreignKey' => 'product_variant_id',
'joinType' => 'INNER',
]);
$this->belongsTo('ProductCategoryVariantOptions', [
@@ -81,8 +81,8 @@ class ProductSkuVariantValuesTable extends Table
->notEmptyString('product_sku_id');
$validator
->uuid('product_category_variant_id')
->notEmptyString('product_category_variant_id');
->uuid('product_variant_id')
->notEmptyString('product_variant_id');
$validator
->uuid('product_category_variant_option_id')
@@ -103,8 +103,8 @@ class ProductSkuVariantValuesTable extends Table
$rules->add($rules->existsIn(['product_sku_id'], 'ProductSkus'), ['errorField' => 'product_sku_id']);
// @TODO why not working?? causing tests to fail / associated variant values not saving on product-skus/add
// $rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
// $rules->add($rules->existsIn(['product_category_variant_option_id'], 'ProductCategoryVariantOptions'), ['errorField' => 'product_category_variant_option_id']);
$rules->add($rules->existsIn(['product_variant_id'], 'ProductVariants'), ['errorField' => 'product_variant_id']);
$rules->add($rules->existsIn(['product_category_variant_option_id'], 'ProductCategoryVariantOptions'), ['errorField' => 'product_category_variant_option_id']);
return $rules;
}