diff --git a/config/Migrations/20251101150009_AllowProductIdToBeNullInProductPhotos.php b/config/Migrations/20251101150009_AllowProductIdToBeNullInProductPhotos.php new file mode 100644 index 0000000..a18fb7c --- /dev/null +++ b/config/Migrations/20251101150009_AllowProductIdToBeNullInProductPhotos.php @@ -0,0 +1,25 @@ +table('product_photos'); + $table->changeColumn('product_id', 'uuid', [ + 'default' => null, + 'limit' => 11, + 'null' => true, + ]); + $table->update(); + } +} diff --git a/src/Model/Entity/ProductPhoto.php b/src/Model/Entity/ProductPhoto.php index a925d3a..4a3056e 100644 --- a/src/Model/Entity/ProductPhoto.php +++ b/src/Model/Entity/ProductPhoto.php @@ -10,7 +10,7 @@ use Cake\ORM\Entity; * ProductPhoto Entity * * @property string $id - * @property string $product_id + * @property string|null $product_id * @property string|null $product_category_id * @property string|null $product_sku_id * @property string $photo_dir @@ -55,6 +55,8 @@ class ProductPhoto extends Entity 'deleted' => true, // entities - 'product' => true, + 'product' => false, + 'product_sku' => false, + 'product_category' => false, ]; } diff --git a/src/Model/Table/ProductCategoryAttributeOptionsTable.php b/src/Model/Table/ProductCategoryAttributeOptionsTable.php index e224c6a..54e1e57 100644 --- a/src/Model/Table/ProductCategoryAttributeOptionsTable.php +++ b/src/Model/Table/ProductCategoryAttributeOptionsTable.php @@ -108,6 +108,7 @@ class ProductCategoryAttributeOptionsTable extends Table public function buildRules(RulesChecker $rules): RulesChecker { $rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']); + $rules->add($rules->isUnique(['attribute_value', 'product_category_attribute_id'])); return $rules; } diff --git a/src/Model/Table/ProductCategoryVariantOptionsTable.php b/src/Model/Table/ProductCategoryVariantOptionsTable.php index 954ec11..f564fa4 100644 --- a/src/Model/Table/ProductCategoryVariantOptionsTable.php +++ b/src/Model/Table/ProductCategoryVariantOptionsTable.php @@ -105,6 +105,7 @@ class ProductCategoryVariantOptionsTable extends Table public function buildRules(RulesChecker $rules): RulesChecker { $rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']); + $rules->add($rules->isUnique(['variant_value', 'product_category_variant_id'])); return $rules; }