category photos should be working

This commit is contained in:
2025-10-12 01:04:36 -07:00
parent 66db31c7ad
commit 30aad1dea4
11 changed files with 105 additions and 9 deletions

View File

@@ -45,7 +45,7 @@ class ProductPhotosController extends AppController
*/
public function view($id = null)
{
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus']);
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']);
$this->set(compact('productPhoto'));
}
@@ -94,6 +94,7 @@ class ProductPhotosController extends AppController
if (!file_exists($destination)) {
throw new ForbiddenException('Failed to move the uploaded image to the appropriate folder. Please try again.');
}
$postData['product_category_id'] = $product->product_category_id ?? null;
$postData['photo_dir'] = $path;
$postData['photo_filename'] = $uuid;
$productPhoto = $productPhotosTable->patchEntity($productPhoto, $postData);
@@ -102,6 +103,8 @@ class ProductPhotosController extends AppController
return $this->redirect(['action' => 'index']);
}
dd($productPhoto->product_category_id);
// dd(print_r($productPhoto->getErrors(), true));
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
}
$products = $productPhotosTable->Products->find('list', limit: 200)->all();