This commit is contained in:
2025-04-01 01:00:09 -07:00
parent fad4f575b8
commit 17de2e97dd
8 changed files with 69 additions and 14 deletions

View File

@@ -60,7 +60,9 @@ class ProductCategoriesController extends AppController
'ProductCategoryAttributes',
'ProductCategoryAttributes.ProductCategoryAttributeOptions',
]);
$this->set(compact('productCategory'));
$productCategoryAttributes = $this->getTable()->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id);
$this->set(compact('productCategory', 'productCategoryAttributes'));
}
/**

View File

@@ -61,6 +61,7 @@ class ProductCategoryAttributesController extends AppController
'ProductCategories',
'ProductCategoryAttributeOptions',
]);
$this->set(compact('productCategoryAttribute'));
}
@@ -165,4 +166,11 @@ class ProductCategoryAttributesController extends AppController
return $this->redirect(['action' => 'index']);
}
public function form($categoryId = null)
{
$productCategoryAttributes = $this->getTable()->getAllCategoryAttributesForCategoryId($categoryId);
$this->set(compact('productCategoryAttributes'));
}
}

View File

@@ -77,8 +77,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', keyField: 'internal_id', valueField: 'name' )->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'));
}
/**