bring into standalone plugin for distribution

This commit is contained in:
2024-11-24 18:38:29 -08:00
parent 279d46f14b
commit ded60d16bf
83 changed files with 7020 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateProductCatalogs extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('product_catalogs', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('catalog_description', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
]);
$table->addColumn('enabled', 'boolean', [
'default' => null,
'null' => false,
]);
$table->addIndex([
'name',
], [
'name' => 'BY_NAME',
'unique' => true,
]);
$table->create();
}
}

View File

@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateProductCategories extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('product_categories');
$table->addColumn('product_catalog_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('internal_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('category_description', 'text', [
'default' => null,
'null' => true,
]);
// $table->addColumn('shopify_v1_id', 'integer', [
// 'default' => null,
// 'limit' => 11,
// 'null' => true,
// ]);
// $table->addColumn('shopify_v2_id', 'string', [
// 'default' => null,
// 'limit' => 255,
// 'null' => true,
// ]);
$table->addColumn('parent_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => true,
]);
$table->addColumn('lft', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('rght', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('enabled', 'boolean', [
'default' => false,
'null' => false,
]);
$table->addIndex('parent_id');
$table->addIndex('lft');
$table->addIndex('product_catalog_id');
$table->addIndex([
'product_catalog_id',
'name',
], [
'name' => 'BY_NAME_AND_CATALOG_ID',
'unique' => true,
]);
$table->create();
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateProducts extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('products', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('product_category_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('product_type_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addIndex('product_category_id');
$table->addIndex('product_type_id');
$table->addIndex([
'product_category_id',
'name',
], [
'name' => 'BY_NAME_AND_CATEGORY_ID',
'unique' => true,
]);
$table->create();
}
}

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateProductCategoryAttributes extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('product_category_attributes', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('name', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('product_category_id', 'uuid', [
'default' => null,
'null' => true,
]);
$table->addColumn('attribute_type_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('enabled', 'boolean', [
'default' => null,
'null' => false,
]);
$table->addIndex([
'product_category_id',
], [
'name' => 'BY_PRODUCT_CATEGORY_ID',
'unique' => false,
]);
$table->addIndex([
'name',
'product_category_id',
], [
'name' => 'BY_NAME_AND_PRODUCT_CATEGORY_ID_UNIQUE',
'unique' => true,
]);
$table->create();
}
}

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateProductCategoryAttributeOptions extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('product_category_attribute_options', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('product_category_attribute_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('attribute_value', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('attribute_label', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('enabled', 'boolean', [
'default' => true,
'null' => false,
]);
$table->addIndex([
'product_category_attribute_id',
], [
'name' => 'BY_PRODUCT_CATEGORY_ATTRIBUTE_ID',
'unique' => false,
]);
$table->create();
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateExternalProductCatalogs extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('external_product_catalogs');
$table->addColumn('product_catalog_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('base_url', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('api_url', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('created', 'datetime', [
'default' => null,
'null' => false,
]);
$table->addColumn('deleted', 'datetime', [
'default' => null,
'null' => true,
]);
$table->addColumn('enabled', 'boolean', [
'default' => null,
'null' => false,
]);
$table->addIndex([
'product_catalog_id',
], [
'name' => 'BY_PRODUCT_CATALOG_ID',
'unique' => false,
]);
$table->create();
}
}

28
config/app.example.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// The following configs can be globally configured, copy the array content over to your ROOT/config
return [
'CakeProducts' => [
/**
* internal CakeProducts settings - used in the source of truth/internal only system.
* Can optionally manage external catalogs
*
* - syncExternally - defaults to false - product catalogs can have 1 or more external catalogs linked to them
* which will receive changes to the catalogs and optionally allow for external API access.
* Will have no effect if true but no external catalogs have been added or none are enabled
*/
'internal' => [
'enabled' => true,
/**
* syncExternally defaults to false - product catalogs can have 1 or more external catalogs linked to them
* which will receive changes to the catalogs and optionally allow for external API access.
* Will have no effect if true but no external catalogs have been added or none are enabled
*/
'syncExternally' => false,
],
'external' => [ // product catalog settings for external use (as an API server to power an ecommerce site for example)
'enabled' => false,
],
],
];