default product type id on categories table
CI / testsuite (mysql, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (mysql, 8.4, ) (push) Failing after 0s
Details
CI / testsuite (pgsql, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (pgsql, 8.4, ) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.1, prefer-lowest) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.4, ) (push) Failing after 0s
Details
CI / Coding Standard & Static Analysis (push) Failing after 0s
Details
CI / testsuite (mysql, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (mysql, 8.4, ) (push) Failing after 0s
Details
CI / testsuite (pgsql, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (pgsql, 8.4, ) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.1, ) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.1, prefer-lowest) (push) Failing after 0s
Details
CI / testsuite (sqlite, 8.4, ) (push) Failing after 0s
Details
CI / Coding Standard & Static Analysis (push) Failing after 0s
Details
This commit is contained in:
parent
59a38758e9
commit
9d777f12b2
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Migrations\BaseMigration;
|
||||||
|
|
||||||
|
class AddDefaultProductTypeIdToProductCategories 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_categories');
|
||||||
|
$table->addColumn('default_product_type_id', 'integer', [
|
||||||
|
'default' => null,
|
||||||
|
'limit' => 11,
|
||||||
|
'null' => true,
|
||||||
|
]);
|
||||||
|
$table->update();
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,7 +37,7 @@ class ProductCategoryVariantsController extends AppController
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$query = $this->getTable()->find()
|
$query = $this->getTable()->find()
|
||||||
->contain(['ProductCategories', 'Products']);
|
->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||||
$productCategoryVariants = $this->paginate($query);
|
$productCategoryVariants = $this->paginate($query);
|
||||||
|
|
||||||
$this->set(compact('productCategoryVariants'));
|
$this->set(compact('productCategoryVariants'));
|
||||||
|
@ -52,7 +52,7 @@ class ProductCategoryVariantsController extends AppController
|
||||||
*/
|
*/
|
||||||
public function view($id = null)
|
public function view($id = null)
|
||||||
{
|
{
|
||||||
$productCategoryVariant = $this->getTable()->get($id, contain: ['ProductCategories', 'Products']);
|
$productCategoryVariant = $this->getTable()->get($id, contain: ['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||||
$this->set(compact('productCategoryVariant'));
|
$this->set(compact('productCategoryVariant'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class ProductCategoryVariantsController extends AppController
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
||||||
if ($productCategoryVariantsTable->save($productCategoryVariant)) {
|
if ($productCategoryVariantsTable->save($productCategoryVariant, $saveOptions)) {
|
||||||
$this->Flash->success(__('The product category variant has been saved.'));
|
$this->Flash->success(__('The product category variant has been saved.'));
|
||||||
|
|
||||||
return $this->redirect(['action' => 'index']);
|
return $this->redirect(['action' => 'index']);
|
||||||
|
@ -103,8 +103,17 @@ class ProductCategoryVariantsController extends AppController
|
||||||
$productCategoryVariantsTable = $this->getTable();
|
$productCategoryVariantsTable = $this->getTable();
|
||||||
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
|
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
|
||||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $this->request->getData());
|
$postData = $this->request->getData();
|
||||||
if ($productCategoryVariantsTable->save($productCategoryVariant)) {
|
// if ($this->request->getSession()->read('Auth.User.id')) {
|
||||||
|
// $postData['created_by'] = $this->request->getSession()->read('Auth.User.id');
|
||||||
|
// }
|
||||||
|
$saveOptions = [
|
||||||
|
'associated' => [
|
||||||
|
'ProductCategoryVariantOptions'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
||||||
|
if ($productCategoryVariantsTable->save($productCategoryVariant, $saveOptions)) {
|
||||||
$this->Flash->success(__('The product category variant has been saved.'));
|
$this->Flash->success(__('The product category variant has been saved.'));
|
||||||
|
|
||||||
return $this->redirect(['action' => 'index']);
|
return $this->redirect(['action' => 'index']);
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace CakeProducts\Model\Entity;
|
||||||
|
|
||||||
use Cake\I18n\DateTime;
|
use Cake\I18n\DateTime;
|
||||||
use Cake\ORM\Entity;
|
use Cake\ORM\Entity;
|
||||||
|
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product Entity
|
* Product Entity
|
||||||
|
@ -12,11 +13,13 @@ use Cake\ORM\Entity;
|
||||||
* @property string $id
|
* @property string $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $product_category_id
|
* @property string $product_category_id
|
||||||
* @property \CakeProducts\Model\Enum\ProductProductTypeId $product_type_id
|
* @property ProductProductTypeId $product_type_id
|
||||||
* @property DateTime|null $deleted
|
* @property DateTime|null $deleted
|
||||||
*
|
*
|
||||||
* @property \CakeProducts\Model\Entity\ProductCategory $product_category
|
* @property ProductCategory $product_category
|
||||||
* @property \CakeProducts\Model\Entity\ProductAttribute[] $product_attributes
|
* @property ProductAttribute[] $product_attributes
|
||||||
|
* @property ProductCategoryVariant[] $product_category_variants
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class Product extends Entity
|
class Product extends Entity
|
||||||
{
|
{
|
||||||
|
@ -37,5 +40,6 @@ class Product extends Entity
|
||||||
// entities
|
// entities
|
||||||
'product_category' => false,
|
'product_category' => false,
|
||||||
'product_attributes' => true,
|
'product_attributes' => true,
|
||||||
|
'product_category_variants' => false,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace CakeProducts\Model\Entity;
|
||||||
|
|
||||||
use Cake\I18n\DateTime;
|
use Cake\I18n\DateTime;
|
||||||
use Cake\ORM\Entity;
|
use Cake\ORM\Entity;
|
||||||
|
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProductCategory Entity
|
* ProductCategory Entity
|
||||||
|
@ -19,6 +20,7 @@ use Cake\ORM\Entity;
|
||||||
* @property int $rght
|
* @property int $rght
|
||||||
* @property bool $enabled
|
* @property bool $enabled
|
||||||
* @property DateTime|null $deleted
|
* @property DateTime|null $deleted
|
||||||
|
* @property ProductProductTypeId|null $default_product_type_id
|
||||||
*
|
*
|
||||||
* @property \CakeProducts\Model\Entity\ProductCatalog $product_catalog
|
* @property \CakeProducts\Model\Entity\ProductCatalog $product_catalog
|
||||||
* @property \CakeProducts\Model\Entity\ParentProductCategory $parent_product_category
|
* @property \CakeProducts\Model\Entity\ParentProductCategory $parent_product_category
|
||||||
|
@ -40,6 +42,7 @@ class ProductCategory extends Entity
|
||||||
'internal_id' => true,
|
'internal_id' => true,
|
||||||
'name' => true,
|
'name' => true,
|
||||||
'category_description' => true,
|
'category_description' => true,
|
||||||
|
'default_product_type_id' => true,
|
||||||
'parent_id' => true,
|
'parent_id' => true,
|
||||||
'lft' => true,
|
'lft' => true,
|
||||||
'rght' => true,
|
'rght' => true,
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
namespace CakeProducts\Model\Table;
|
namespace CakeProducts\Model\Table;
|
||||||
|
|
||||||
use Cake\Core\Configure;
|
use Cake\Core\Configure;
|
||||||
|
use Cake\Database\Type\EnumType;
|
||||||
use Cake\Datasource\EntityInterface;
|
use Cake\Datasource\EntityInterface;
|
||||||
use Cake\Datasource\ResultSetInterface;
|
use Cake\Datasource\ResultSetInterface;
|
||||||
use Cake\ORM\Association\BelongsTo;
|
use Cake\ORM\Association\BelongsTo;
|
||||||
|
@ -14,6 +15,7 @@ use Cake\ORM\RulesChecker;
|
||||||
use Cake\ORM\Table;
|
use Cake\ORM\Table;
|
||||||
use Cake\Validation\Validator;
|
use Cake\Validation\Validator;
|
||||||
use CakeProducts\Model\Entity\ProductCategory;
|
use CakeProducts\Model\Entity\ProductCategory;
|
||||||
|
use CakeProducts\Model\Enum\ProductProductTypeId;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Psr\SimpleCache\CacheInterface;
|
use Psr\SimpleCache\CacheInterface;
|
||||||
|
|
||||||
|
@ -99,6 +101,8 @@ class ProductCategoriesTable extends Table
|
||||||
'cascadeCallbacks' => true,
|
'cascadeCallbacks' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->getSchema()->setColumnType('default_product_type_id', EnumType::from(ProductProductTypeId::class));
|
||||||
|
|
||||||
$this->behaviors()->Tree->setConfig('scope', ['product_catalog_id' => $this->treeCatalogId]);
|
$this->behaviors()->Tree->setConfig('scope', ['product_catalog_id' => $this->treeCatalogId]);
|
||||||
$this->addBehavior('Muffin/Trash.Trash');
|
$this->addBehavior('Muffin/Trash.Trash');
|
||||||
}
|
}
|
||||||
|
@ -137,6 +141,10 @@ class ProductCategoriesTable extends Table
|
||||||
->dateTime('deleted')
|
->dateTime('deleted')
|
||||||
->allowEmptyDateTime('deleted');
|
->allowEmptyDateTime('deleted');
|
||||||
|
|
||||||
|
$validator
|
||||||
|
->integer('default_product_type_id')
|
||||||
|
->allowEmptyString('default_product_type_id');
|
||||||
|
|
||||||
return $validator;
|
return $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<th><?= $this->Paginator->sort('product_id') ?></th>
|
<th><?= $this->Paginator->sort('product_id') ?></th>
|
||||||
<th><?= $this->Paginator->sort('attribute_type_id') ?></th>
|
<th><?= $this->Paginator->sort('attribute_type_id') ?></th>
|
||||||
<th><?= $this->Paginator->sort('enabled') ?></th>
|
<th><?= $this->Paginator->sort('enabled') ?></th>
|
||||||
|
<th><?= 'Options' ?></th>
|
||||||
<th class="actions"><?= __('Actions') ?></th>
|
<th class="actions"><?= __('Actions') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -29,6 +30,15 @@
|
||||||
<td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td>
|
<td><?= $productCategoryVariant->hasValue('product') ? $this->Html->link($productCategoryVariant->product->name, ['controller' => 'Products', 'action' => 'view', $productCategoryVariant->product->id]) : '' ?></td>
|
||||||
<td><?= $this->Number->format($productCategoryVariant->attribute_type_id) ?></td>
|
<td><?= $this->Number->format($productCategoryVariant->attribute_type_id) ?></td>
|
||||||
<td><?= h($productCategoryVariant->enabled) ?></td>
|
<td><?= h($productCategoryVariant->enabled) ?></td>
|
||||||
|
<td>
|
||||||
|
<small>
|
||||||
|
<?php
|
||||||
|
$cnt = isset($productCategoryVariant->product_category_variant_options) && $productCategoryVariant->product_category_variant_options ? count($productCategoryVariant->product_category_variant_options) : 0;
|
||||||
|
foreach ($productCategoryVariant->product_category_variant_options as $index => $productCategoryVariantOption) : ?>
|
||||||
|
<?= h($productCategoryVariantOption->variant_value); ?><?= $index < ($cnt -1) ? ', ' : ''; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</small>
|
||||||
|
</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<?= $this->Html->link(__('View'), ['action' => 'view', $productCategoryVariant->id]) ?>
|
<?= $this->Html->link(__('View'), ['action' => 'view', $productCategoryVariant->id]) ?>
|
||||||
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $productCategoryVariant->id]) ?>
|
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $productCategoryVariant->id]) ?>
|
||||||
|
|
|
@ -26,5 +26,6 @@ echo $this->Form->control('parent_id', [
|
||||||
'empty' => true,
|
'empty' => true,
|
||||||
'id' => 'product_category_parent_id',
|
'id' => 'product_category_parent_id',
|
||||||
]);
|
]);
|
||||||
|
echo $this->Form->control('default_product_type_id');
|
||||||
echo $this->Form->control('enabled');
|
echo $this->Form->control('enabled');
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue