default product type id on categories table
This commit is contained in:
@@ -37,7 +37,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
->contain(['ProductCategories', 'Products']);
|
||||
->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||
$productCategoryVariants = $this->paginate($query);
|
||||
|
||||
$this->set(compact('productCategoryVariants'));
|
||||
@@ -52,7 +52,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
*/
|
||||
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'));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ProductCategoryVariantsController extends AppController
|
||||
],
|
||||
];
|
||||
$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.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
@@ -103,8 +103,17 @@ class ProductCategoryVariantsController extends AppController
|
||||
$productCategoryVariantsTable = $this->getTable();
|
||||
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $this->request->getData());
|
||||
if ($productCategoryVariantsTable->save($productCategoryVariant)) {
|
||||
$postData = $this->request->getData();
|
||||
// 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.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
|
||||
Reference in New Issue
Block a user