product attributes on edit product
This commit is contained in:
@@ -107,9 +107,16 @@ class ProductsController extends AppController
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productsTable = $this->getTable();
|
||||
$product = $productsTable->get($id, contain: []);
|
||||
$product = $productsTable->get($id, contain: [
|
||||
'ProductAttributes',
|
||||
'ProductAttributes.ProductCategoryAttributes',
|
||||
'ProductAttributes.ProductCategoryAttributes.ProductCategoryAttributeOptions',
|
||||
]);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$product = $productsTable->patchEntity($product, $this->request->getData());
|
||||
$saveOptions = [
|
||||
'associated' => ['ProductAttributes'],
|
||||
];
|
||||
$product = $productsTable->patchEntity($product, $this->request->getData(), $saveOptions);
|
||||
if ($productsTable->save($product)) {
|
||||
$this->Flash->success(__('The product has been saved.'));
|
||||
|
||||
@@ -122,6 +129,7 @@ class ProductsController extends AppController
|
||||
$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