attributes form wip
This commit is contained in:
@@ -161,13 +161,10 @@ class ProductCategoriesController extends AppController
|
||||
'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1),
|
||||
],
|
||||
]);
|
||||
$form = $this->request->getQuery('form', 'product_category');
|
||||
if ($form === 'product') {
|
||||
$productCategoriesQ = $productCategoriesTable
|
||||
->find('treeList', keyPath: 'internal_id', valuePath: 'name');
|
||||
} else {
|
||||
$productCategoriesQ = $productCategoriesTable->find('treeList');
|
||||
}
|
||||
$productCategoriesQ = $this->request->getQuery('form', 'product_category') === 'product' ?
|
||||
$productCategoriesTable->find('treeList', keyPath: 'internal_id', valuePath: 'name') :
|
||||
$productCategoriesTable->find('treeList');
|
||||
|
||||
$productCategories = $productCategoriesQ
|
||||
->orderBy(['ProductCategories.name'])
|
||||
->toArray();
|
||||
|
||||
@@ -114,11 +114,16 @@ class ProductCategoryAttributesTable extends Table
|
||||
public function getAllCategoryAttributesForCategoryId(string $internalCategoryId)
|
||||
{
|
||||
$category = $this->ProductCategories->find()->where(['internal_id' => $internalCategoryId])->first();
|
||||
$categories = [];
|
||||
if ($category) {
|
||||
$categories = $this->ProductCategories->find('path', for: $category->id)->all();
|
||||
}
|
||||
|
||||
return $categories;
|
||||
$this->ProductCategories->behaviors()->get('Tree')->setConfig([
|
||||
'scope' => [
|
||||
'product_catalog_id' => $category->product_catalog_id ?? 1,
|
||||
],
|
||||
]);
|
||||
|
||||
return $category ? $this->ProductCategories
|
||||
->find('path', for: $category->id)
|
||||
->contain(['ProductCategoryAttributes', 'ProductCategoryAttributes.ProductCategoryAttributeOptions'])
|
||||
->toArray() : [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user