subscribtion category variants / system category variants
This commit is contained in:
@@ -111,21 +111,32 @@ class ProductCategoryVariantsController extends AppController
|
||||
// if ($this->request->getSession()->read('Auth.User.id')) {
|
||||
// $postData['created_by'] = $this->request->getSession()->read('Auth.User.id');
|
||||
// }
|
||||
$postData = $productCategoryVariant->is_system_variant ? ['product_category_variant_options' => $this->request->getData('product_category_variant_options')] : $postData;
|
||||
$saveOptions = [
|
||||
'fields' => $productCategoryVariant->is_system_variant ? [
|
||||
'product_category_variant_options',
|
||||
] : [
|
||||
'name',
|
||||
'product_category_id',
|
||||
'enabled',
|
||||
'product_category_variant_options',
|
||||
],
|
||||
'associated' => [
|
||||
'ProductCategoryVariantOptions'
|
||||
],
|
||||
];
|
||||
$productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions);
|
||||
// dd($postData);
|
||||
if ($productCategoryVariantsTable->save($productCategoryVariant, $saveOptions)) {
|
||||
$this->Flash->success(__('The product category variant has been saved.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
// dd($productCategoryVariant->getErrors());
|
||||
$this->Flash->error(__('The product category variant could not be saved. Please, try again.'));
|
||||
}
|
||||
$productCategories = $productCategoryVariantsTable->ProductCategories->find('list', keyField: 'internal_id', valueField: 'name')->all();
|
||||
$products = $productCategoryVariantsTable->Products->find('list', limit: 200)->where(['product_category_id' => $productCategoryVariant->product_category_id])->all();
|
||||
$products = isset($productCategoryVariant->product_category_id) ? $productCategoryVariantsTable->Products->find('list', limit: 200)->where(['product_category_id' => $productCategoryVariant->product_category_id])->all() : [];
|
||||
$this->set(compact('productCategoryVariant', 'productCategories', 'products'));
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class ProductPhotosController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
dd($productPhoto->getErrors());
|
||||
// dd($productPhoto->getErrors());
|
||||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$productCategory = $productPhoto->product_category_id ? $productPhotosTable->ProductCategories->find()->where(['internal_id' => $productPhoto->product_category_id ?? '-1'])->first() : null;
|
||||
|
||||
Reference in New Issue
Block a user