product attributes
This commit is contained in:
@@ -67,8 +67,16 @@ class ProductsController extends AppController
|
||||
$productsTable = $this->getTable();
|
||||
$product = $productsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$product = $productsTable->patchEntity($product, $this->request->getData());
|
||||
if ($productsTable->save($product)) {
|
||||
$postData = $this->request->getData();
|
||||
$saveOptions = [
|
||||
'associated' => ['ProductAttributes'],
|
||||
];
|
||||
// Log::debug(print_r('$postData', true));
|
||||
// Log::debug(print_r($postData, true));
|
||||
// Log::debug(print_r('$saveOptions', true));
|
||||
// Log::debug(print_r($saveOptions, true));
|
||||
$product = $productsTable->patchEntity($product, $postData, $saveOptions);
|
||||
if ($productsTable->save($product, $saveOptions)) {
|
||||
$this->Flash->success(__('The product has been saved.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
@@ -104,8 +112,9 @@ class ProductsController extends AppController
|
||||
Log::debug(print_r($product->getErrors(), true));
|
||||
$this->Flash->error(__('The product could not be saved. Please, try again.'));
|
||||
}
|
||||
$productCategories = $productsTable->ProductCategories->find('list', limit: 200)->all();
|
||||
$this->set(compact('product', 'productCategories'));
|
||||
$productCategory = $product->product_category_id ? $productsTable->ProductCategories->find()->where(['internal_id' => $product->product_category_id])->first() : null;
|
||||
$productCatalogs = $productsTable->ProductCategories->ProductCatalogs->find('list')->toArray();
|
||||
$this->set(compact('product', 'productCatalogs', 'productCategory'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user