default sku boolean to product skus table
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Waiting to run Details
CI / Coding Standard & Static Analysis (push) Waiting to run Details
CI / testsuite (mysql, 8.2, ) (push) Failing after 6m11s Details
CI / testsuite (mysql, 8.4, ) (push) Has been cancelled Details

This commit is contained in:
Brandon Shipley 2025-10-06 23:21:50 -07:00
parent 81a9f827db
commit 25957f7d8b
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
class AddDefaultSkuToProductSkus extends BaseMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('product_skus');
$table->addColumn('default_sku', 'boolean', [
'default' => false,
'limit' => 11,
'null' => false,
]);
$table->update();
}
}

View File

@ -97,6 +97,13 @@ class ProductsTable extends Table
'dependent' => true, 'dependent' => true,
]); ]);
$this->hasOne('DefaultProductSkus', [
'foreignKey' => 'product_id',
'conditions' => ['PrimaryProductSkus.default_sku' => true],
'className' => 'CakeProducts.ProductSkus',
'dependent' => true,
]);
$this->getSchema()->setColumnType('product_type_id', EnumType::from(ProductProductTypeId::class)); $this->getSchema()->setColumnType('product_type_id', EnumType::from(ProductProductTypeId::class));
$this->addBehavior('Muffin/Trash.Trash'); $this->addBehavior('Muffin/Trash.Trash');

View File

@ -26,6 +26,8 @@ class ProductsTableTest extends TestCase
protected array $fixtures = [ protected array $fixtures = [
'plugin.CakeProducts.Products', 'plugin.CakeProducts.Products',
'plugin.CakeProducts.ProductCategories', 'plugin.CakeProducts.ProductCategories',
'plugin.CakeProducts.ProductSkus',
'plugin.CakeProducts.ProductSkuVariantValues',
]; ];
/** /**
@ -68,6 +70,7 @@ class ProductsTableTest extends TestCase
'ProductSkus', 'ProductSkus',
'ProductPhotos', 'ProductPhotos',
'PrimaryProductPhotos', 'PrimaryProductPhotos',
'DefaultProductSkus',
]; ];
$associations = $this->Products->associations(); $associations = $this->Products->associations();