variants controller tests failing

This commit is contained in:
2025-08-21 22:43:06 -07:00
parent 8bdb329828
commit b9bf47f385
4 changed files with 34 additions and 24 deletions

View File

@@ -52,7 +52,11 @@ class ProductCategoryVariantsController extends AppController
*/
public function view($id = null)
{
$productCategoryVariant = $this->getTable()->get($id, contain: ['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
$productCategoryVariant = $this->getTable()->get($id, contain: [
'ProductCategories',
'Products',
'ProductCategoryVariantOptions',
]);
$this->set(compact('productCategoryVariant'));
}

View File

@@ -4,16 +4,19 @@ declare(strict_types=1);
namespace CakeProducts\Controller;
use Cake\Core\Configure;
use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Http\Exception\ForbiddenException;
use Cake\Http\Response;
use Cake\Utility\Text;
use CakeProducts\Controller\AppController;
use CakeProducts\Model\Table\ProductPhotosTable;
use CheeseCake\Controller\Traits\OverrideTableTrait;
use Psr\Http\Message\UploadedFileInterface;
/**
* ProductPhotos Controller
*
* @property \CakeProducts\Model\Table\ProductPhotosTable $ProductPhotos
* @property ProductPhotosTable $ProductPhotos
*/
class ProductPhotosController extends AppController
{
@@ -22,12 +25,12 @@ class ProductPhotosController extends AppController
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
* @return Response|null|void Renders view
*/
public function index()
{
$query = $this->getTable()->find()
->contain(['Products']);
->contain(['Products', 'ProductSkus']);
$productPhotos = $this->paginate($query);
$this->set(compact('productPhotos'));
@@ -37,19 +40,19 @@ class ProductPhotosController extends AppController
* View method
*
* @param string|null $id Product Photo id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null|void Renders view
* @throws RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$productPhoto = $this->getTable()->get($id, contain: ['Products']);
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus']);
$this->set(compact('productPhoto'));
}
/**
* Add method
*
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
* @return Response|null|void Redirects on successful add, renders view otherwise.
*/
public function add()
{
@@ -101,16 +104,17 @@ class ProductPhotosController extends AppController
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
}
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
$this->set(compact('productPhoto', 'products'));
$this->set(compact('productPhoto', 'products', 'productSkus'));
}
/**
* Edit method
*
* @param string|null $id Product Photo id.
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null|void Redirects on successful edit, renders view otherwise.
* @throws RecordNotFoundException When record not found.
*/
public function edit($id = null)
{
@@ -128,15 +132,16 @@ class ProductPhotosController extends AppController
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
}
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
$this->set(compact('productPhoto', 'products'));
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
$this->set(compact('productPhoto', 'products', 'productSkus'));
}
/**
* Delete method
*
* @param string|null $id Product Photo id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null Redirects to index.
* @throws RecordNotFoundException When record not found.
*/
public function delete($id = null)
{

View File

@@ -7,7 +7,6 @@ use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface;
use Cake\ORM\Association\BelongsTo;
use Cake\ORM\Behavior\TimestampBehavior;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;