dont use cheese cake override table trait - dont think is necessary
This commit is contained in:
parent
c8e44f3705
commit
c196dc2fe0
|
|
@ -8,7 +8,6 @@
|
|||
"php": ">=8.2",
|
||||
"dereuromark/cakephp-tools": "^3.9",
|
||||
"muffin/trash": "^4.2",
|
||||
"hi-powered-dev/cheese-cake": "dev-prod",
|
||||
"cakephp/cakephp": "^5.0.1",
|
||||
"bentools/cartesian-product": "dev-master"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ use Cake\Core\Configure;
|
|||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogs Controller
|
||||
|
|
@ -17,7 +15,7 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
|
|||
*/
|
||||
class ExternalProductCatalogsController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
// use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace CakeProducts\Controller;
|
|||
use Cake\Datasource\Exception\RecordNotFoundException;
|
||||
use Cake\Http\Response;
|
||||
use Cake\Log\Log;
|
||||
use CakeProducts\Controller\AppController;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogsProductCatalogs Controller
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ use Cake\Http\Response;
|
|||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
|
||||
/**
|
||||
|
|
@ -21,8 +18,6 @@ use CakeProducts\Model\Table\ProductCatalogsTable;
|
|||
*/
|
||||
class ProductCatalogsController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -40,7 +35,7 @@ class ProductCatalogsController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find();
|
||||
$query = $this->ProductCatalogs->find();
|
||||
$productCatalogs = $this->paginate($query);
|
||||
|
||||
$this->set(compact('productCatalogs'));
|
||||
|
|
@ -59,7 +54,7 @@ class ProductCatalogsController extends AppController
|
|||
if (Configure::read('CakeProducts.internal.syncExternally', false)) {
|
||||
$contain[] = 'ExternalProductCatalogs';
|
||||
}
|
||||
$productCatalog = $this->getTable()->get($id, contain: $contain);
|
||||
$productCatalog = $this->ProductCatalogs->get($id, contain: $contain);
|
||||
$this->set(compact('productCatalog'));
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +65,7 @@ class ProductCatalogsController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productCatalogsTable = $this->getTable();
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData());
|
||||
|
|
@ -97,7 +92,7 @@ class ProductCatalogsController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productCatalogsTable = $this->getTable();
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData());
|
||||
|
|
@ -121,7 +116,7 @@ class ProductCatalogsController extends AppController
|
|||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCatalogsTable = $this->getTable();
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
$productCatalog = $productCatalogsTable->get($id);
|
||||
if ($productCatalogsTable->delete($productCatalog)) {
|
||||
$this->Flash->success(__('The product catalog has been deleted.'));
|
||||
|
|
@ -131,21 +126,4 @@ class ProductCatalogsController extends AppController
|
|||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the users table instance
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
if ($this->_table instanceof Table) {
|
||||
return $this->_table;
|
||||
}
|
||||
$this->_table = TableRegistry::getTableLocator()->get(
|
||||
Configure::read('CakeProducts.ProductCatalogs.table', 'CakeProducts.ProductCatalogs')
|
||||
);
|
||||
|
||||
return $this->_table;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ use Cake\Log\Log;
|
|||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\Utility\Text;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
;
|
||||
|
||||
/**
|
||||
* ProductCategories Controller
|
||||
|
|
@ -18,8 +16,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
|
|||
*/
|
||||
class ProductCategoriesController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -37,7 +33,7 @@ class ProductCategoriesController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
$query = $this->ProductCategories->find()
|
||||
->contain(['ProductCatalogs', 'ParentProductCategories']);
|
||||
$productCategories = $this->paginate($query);
|
||||
|
||||
|
|
@ -53,7 +49,7 @@ class ProductCategoriesController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productCategory = $this->getTable()->get($id, contain: [
|
||||
$productCategory = $this->ProductCategories->get($id, contain: [
|
||||
'ProductCatalogs',
|
||||
'ParentProductCategories',
|
||||
'ChildProductCategories',
|
||||
|
|
@ -62,7 +58,7 @@ class ProductCategoriesController extends AppController
|
|||
'PrimaryProductPhotos',
|
||||
]);
|
||||
|
||||
$productCategoryAttributes = $this->getTable()->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id);
|
||||
$productCategoryAttributes = $this->ProductCategories->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id);
|
||||
$this->set(compact('productCategory', 'productCategoryAttributes'));
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +69,7 @@ class ProductCategoriesController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productCategoriesTable = $this->getTable();
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategory = $productCategoriesTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -112,7 +108,7 @@ class ProductCategoriesController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productCategoriesTable = $this->getTable();
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategory = $productCategoriesTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -139,7 +135,7 @@ class ProductCategoriesController extends AppController
|
|||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoriesTable = $this->getTable();
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
|
||||
$productCategory = $productCategoriesTable->get($id);
|
||||
// $productCategoriesTable->behaviors()->get('Tree')->setConfig([
|
||||
|
|
@ -161,7 +157,7 @@ class ProductCategoriesController extends AppController
|
|||
*/
|
||||
public function select()
|
||||
{
|
||||
$productCategoriesTable = $this->getTable();
|
||||
$productCategoriesTable = $this->ProductCategories;
|
||||
$productCategoriesTable->behaviors()->get('Tree')->setConfig([
|
||||
'scope' => [
|
||||
'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1),
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ use Cake\Core\Configure;
|
|||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
;
|
||||
|
||||
/**
|
||||
* ProductCategoryAttributeOptions Controller
|
||||
|
|
@ -18,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
|
|||
*/
|
||||
class ProductCategoryAttributeOptionsController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -39,7 +34,7 @@ class ProductCategoryAttributeOptionsController extends AppController
|
|||
{
|
||||
Log::debug('inside product category attribute options controller add');
|
||||
|
||||
$productCategoryAttributeOption = $this->getTable()->newEmptyEntity();
|
||||
$productCategoryAttributeOption = $this->ProductCategoryAttributeOptions->newEmptyEntity();
|
||||
$this->set(compact('productCategoryAttributeOption'));
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +48,7 @@ class ProductCategoryAttributeOptionsController extends AppController
|
|||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoryAttributeOptionsTable = $this->getTable();
|
||||
$productCategoryAttributeOptionsTable = $this->ProductCategoryAttributeOptions;
|
||||
|
||||
$productCategoryAttributeOption = $productCategoryAttributeOptionsTable->get($id);
|
||||
if ($productCategoryAttributeOptionsTable->delete($productCategoryAttributeOption)) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ use Cake\Http\Response;
|
|||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
|
||||
|
|
@ -21,8 +19,6 @@ use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
|||
*/
|
||||
class ProductCategoryAttributesController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -40,7 +36,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
$query = $this->ProductCategoryAttributes->find()
|
||||
->contain(['ProductCategories']);
|
||||
$productCategoryAttributes = $this->paginate($query);
|
||||
|
||||
|
|
@ -56,7 +52,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productCategoryAttribute = $this->getTable()->get($id, contain: [
|
||||
$productCategoryAttribute = $this->ProductCategoryAttributes->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'ProductCategoryAttributeOptions',
|
||||
]);
|
||||
|
|
@ -71,7 +67,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productCategoryAttributesTable = $this->getTable();
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -113,7 +109,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productCategoryAttributesTable = $this->getTable();
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->get($id, contain: ['ProductCategoryAttributeOptions']);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -155,7 +151,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
|
||||
$productCategoryAttributesTable = $this->getTable();
|
||||
$productCategoryAttributesTable = $this->ProductCategoryAttributes;
|
||||
$productCategoryAttribute = $productCategoryAttributesTable->get($id);
|
||||
if ($productCategoryAttributesTable->delete($productCategoryAttribute)) {
|
||||
$this->Flash->success(__('The product category attribute has been deleted.'));
|
||||
|
|
@ -171,7 +167,7 @@ class ProductCategoryAttributesController extends AppController
|
|||
*/
|
||||
public function form()
|
||||
{
|
||||
$productCategories = $this->getTable()->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1'));
|
||||
$productCategories = $this->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1'));
|
||||
|
||||
$this->set(compact('productCategories'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use App\Controller\AppController;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* ProductCategoryVariants Controller
|
||||
|
|
@ -17,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
|
|||
*/
|
||||
class ProductCategoryVariantsController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -36,7 +32,7 @@ class ProductCategoryVariantsController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
$query = $this->ProductCategoryVariants->find()
|
||||
->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
|
||||
$productCategoryVariants = $this->paginate($query);
|
||||
|
||||
|
|
@ -52,7 +48,7 @@ class ProductCategoryVariantsController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productCategoryVariant = $this->getTable()->get($id, contain: [
|
||||
$productCategoryVariant = $this->ProductCategoryVariants->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'Products',
|
||||
'ProductCategoryVariantOptions',
|
||||
|
|
@ -67,7 +63,7 @@ class ProductCategoryVariantsController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productCategoryVariantsTable = $this->getTable();
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
|
||||
$productCategoryVariant = $productCategoryVariantsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
|
|
@ -104,7 +100,7 @@ class ProductCategoryVariantsController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productCategoryVariantsTable = $this->getTable();
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -150,7 +146,7 @@ class ProductCategoryVariantsController extends AppController
|
|||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productCategoryVariantsTable = $this->getTable();
|
||||
$productCategoryVariantsTable = $this->ProductCategoryVariants;
|
||||
|
||||
$productCategoryVariant = $productCategoryVariantsTable->get($id);
|
||||
if ($productCategoryVariantsTable->delete($productCategoryVariant)) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
@ -20,8 +18,6 @@ use Psr\Http\Message\UploadedFileInterface;
|
|||
*/
|
||||
class ProductPhotosController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
|
|
@ -29,7 +25,7 @@ class ProductPhotosController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
$query = $this->ProductPhotos->find()
|
||||
->contain(['Products', 'ProductSkus', 'ProductCategories']);
|
||||
$productPhotos = $this->paginate($query);
|
||||
|
||||
|
|
@ -45,7 +41,7 @@ class ProductPhotosController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']);
|
||||
$productPhoto = $this->ProductPhotos->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']);
|
||||
$this->set(compact('productPhoto'));
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +52,7 @@ class ProductPhotosController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productPhotosTable = $this->getTable();
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
$productPhoto = $productPhotosTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
if (!$this->request->getData('photo')) {
|
||||
|
|
@ -161,7 +157,7 @@ class ProductPhotosController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productPhotosTable = $this->getTable();
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
$productPhoto = $productPhotosTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -189,7 +185,7 @@ class ProductPhotosController extends AppController
|
|||
public function delete($id = null)
|
||||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
$productPhotosTable = $this->getTable();
|
||||
$productPhotosTable = $this->ProductPhotos;
|
||||
|
||||
$productPhoto = $productPhotosTable->get($id);
|
||||
if ($productPhotosTable->delete($productPhoto)) {
|
||||
|
|
@ -207,7 +203,7 @@ class ProductPhotosController extends AppController
|
|||
*/
|
||||
public function image($id = null)
|
||||
{
|
||||
$productPhoto = $this->getTable()->get($id);
|
||||
$productPhoto = $this->ProductPhotos->get($id);
|
||||
|
||||
$fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace CakeProducts\Controller;
|
|||
|
||||
use Cake\Log\Log;
|
||||
use Cake\Utility\Hash;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
use function BenTools\CartesianProduct\combinations;
|
||||
|
||||
/**
|
||||
|
|
@ -15,8 +14,6 @@ use function BenTools\CartesianProduct\combinations;
|
|||
*/
|
||||
class ProductSkusController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -69,9 +66,7 @@ class ProductSkusController extends AppController
|
|||
{
|
||||
$toGetCartesianProductsFrom = [];
|
||||
$productSkus = [];
|
||||
$table = $this->getTable();
|
||||
|
||||
$product = $table->Products->get($productId, contain: [
|
||||
$product = $this->ProductSkus->Products->get($productId, contain: [
|
||||
'ProductSkus',
|
||||
'ProductSkus.ProductSkuVariantValues',
|
||||
'ProductVariants',
|
||||
|
|
@ -103,7 +98,7 @@ class ProductSkusController extends AppController
|
|||
|
||||
$numSkusToAdd = count(combinations($toGetCartesianProductsFrom));
|
||||
for ($i = 0; $i < $numSkusToAdd; $i++) {
|
||||
$productSkus[$i] = $this->getTable()->newEmptyEntity();
|
||||
$productSkus[$i] = $this->ProductSkus->newEmptyEntity();
|
||||
}
|
||||
$this->set(compact(
|
||||
'product',
|
||||
|
|
@ -159,13 +154,13 @@ class ProductSkusController extends AppController
|
|||
return;
|
||||
}
|
||||
// dd($finalPostData);
|
||||
$productSkus = $table->patchEntities($productSkus, $finalPostData, $saveOptions);
|
||||
$productSkus = $this->ProductSkus->patchEntities($productSkus, $finalPostData, $saveOptions);
|
||||
$errors = [];
|
||||
$successes = [];
|
||||
foreach ($productSkus as $productSkuToSave) {
|
||||
// dd($productSkuToSave);
|
||||
|
||||
if (!$table->save($productSkuToSave, $saveOptions)) {
|
||||
if (!$this->ProductSkus->save($productSkuToSave, $saveOptions)) {
|
||||
Log::debug(print_r('$productSkuToSave->getErrors()', true));
|
||||
Log::debug(print_r($productSkuToSave->getErrors(), true));
|
||||
dd($productSkuToSave->getErrors());
|
||||
|
|
@ -245,7 +240,7 @@ class ProductSkusController extends AppController
|
|||
*/
|
||||
public function select()
|
||||
{
|
||||
$productSkus = $this->getTable()
|
||||
$productSkus = $this->ProductSkus
|
||||
->find('list')
|
||||
->where(['product_id' => $this->request->getQuery('product_id', '-1')])
|
||||
->orderBy(['sku'])
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use App\Controller\AppController;
|
||||
use Cake\Log\Log;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ use Cake\Core\Configure;
|
|||
use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CheeseCake\Controller\Traits\OverrideTableTrait;
|
||||
;
|
||||
|
||||
/**
|
||||
* Products Controller
|
||||
|
|
@ -18,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
|
|||
*/
|
||||
class ProductsController extends AppController
|
||||
{
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -37,7 +32,7 @@ class ProductsController extends AppController
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = $this->getTable()->find()
|
||||
$query = $this->Products->find()
|
||||
->contain(['ProductCategories']);
|
||||
$products = $this->paginate($query);
|
||||
|
||||
|
|
@ -53,7 +48,7 @@ class ProductsController extends AppController
|
|||
*/
|
||||
public function view($id = null)
|
||||
{
|
||||
$product = $this->getTable()->get($id, contain: [
|
||||
$product = $this->Products->get($id, contain: [
|
||||
'ProductCategories',
|
||||
'ProductAttributes',
|
||||
'ProductAttributes.ProductCategoryAttributes',
|
||||
|
|
@ -74,7 +69,7 @@ class ProductsController extends AppController
|
|||
*/
|
||||
public function add()
|
||||
{
|
||||
$productsTable = $this->getTable();
|
||||
$productsTable = $this->Products;
|
||||
$product = $productsTable->newEmptyEntity();
|
||||
if ($this->request->is('post')) {
|
||||
$postData = $this->request->getData();
|
||||
|
|
@ -151,7 +146,7 @@ class ProductsController extends AppController
|
|||
*/
|
||||
public function edit($id = null)
|
||||
{
|
||||
$productsTable = $this->getTable();
|
||||
$productsTable = $this->Products;
|
||||
$product = $productsTable->get($id, contain: [
|
||||
'ProductAttributes',
|
||||
'ProductAttributes.ProductCategoryAttributes',
|
||||
|
|
@ -187,7 +182,7 @@ class ProductsController extends AppController
|
|||
{
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
|
||||
$productsTable = $this->getTable();
|
||||
$productsTable = $this->Products;
|
||||
$product = $productsTable->get($id);
|
||||
if ($productsTable->delete($product)) {
|
||||
$this->Flash->success(__('The product has been deleted.'));
|
||||
|
|
@ -203,7 +198,7 @@ class ProductsController extends AppController
|
|||
*/
|
||||
public function select()
|
||||
{
|
||||
$productsTable = $this->getTable();
|
||||
$productsTable = $this->Products;
|
||||
$productCategory = $productsTable->ProductCategories->find()
|
||||
->where(['id' => $this->request->getQuery('product_category_id', '-1')])
|
||||
->first();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ use FilesystemIterator;
|
|||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
/**
|
||||
* BaseControllerTest
|
||||
*
|
||||
* Used to make logging in easier and to handle folder structure for product images
|
||||
*/
|
||||
class BaseControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ use Cake\TestSuite\TestCase;
|
|||
use CakeProducts\Controller\ExternalProductCatalogsController;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsController
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use Cake\TestSuite\IntegrationTestTrait;
|
|||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsProductCatalogsController::class)]
|
||||
class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
|
|||
use CakeProducts\Controller\ProductCatalogsController;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCatalogsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCatalogsController
|
||||
*/
|
||||
#[CoversClass(ProductCatalogsController::class)]
|
||||
class ProductCatalogsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
|
|||
use CakeProducts\Controller\ProductCategoriesController;
|
||||
use CakeProducts\Model\Table\ProductCategoriesTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoriesController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoriesController
|
||||
*/
|
||||
#[CoversClass(ProductCategoriesController::class)]
|
||||
class ProductCategoriesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ use Cake\ORM\Table;
|
|||
use CakeProducts\Controller\ProductCategoryAttributeOptionsController;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryAttributeOptionsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributeOptionsController
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributeOptionsController::class)]
|
||||
class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
|
|||
use CakeProducts\Controller\ProductCategoryAttributesController;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryAttributesController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryAttributesController
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributesController::class)]
|
||||
class ProductCategoryAttributesControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
|||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductCategoryVariantsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductCategoryVariantsController
|
||||
*/
|
||||
#[CoversClass(ProductCategoryVariantsController::class)]
|
||||
class ProductCategoryVariantsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ use CakeProducts\Model\Table\ProductsTable;
|
|||
use FilesystemIterator;
|
||||
use Laminas\Diactoros\UploadedFile;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use const UPLOAD_ERR_OK;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductPhotosController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductPhotosController
|
||||
*/
|
||||
#[CoversClass(ProductPhotosController::class)]
|
||||
class ProductPhotosControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ use CakeProducts\Model\Table\ProductSkusTable;
|
|||
use CakeProducts\Model\Table\ProductSkuVariantValuesTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductSkusController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductSkusController
|
||||
*/
|
||||
#[CoversClass(ProductSkusController::class)]
|
||||
class ProductSkusControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use CakeProducts\Controller\ProductsController;
|
|||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use PHPUnit\Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Controller\ProductsController Test Case
|
||||
*
|
||||
* @uses \CakeProducts\Controller\ProductsController
|
||||
*/
|
||||
#[CoversClass(ProductsController::class)]
|
||||
class ProductsControllerTest extends BaseControllerTest
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ExternalProductCatalogsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ExternalProductCatalogsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ExternalProductCatalogsTable::class)]
|
||||
class ExternalProductCatalogsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
use Cake\ORM\Table;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductCatalogsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCatalogsTable::class)]
|
||||
class ProductCatalogsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCategoriesTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductCategoriesTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoriesTable::class)]
|
||||
class ProductCategoriesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributeOptionsTable::class)]
|
||||
class ProductCategoryAttributeOptionsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductCategoryAttributesTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductCategoryAttributesTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryAttributesTable::class)]
|
||||
class ProductCategoryAttributesTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
|
||||
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* App\Model\Table\ProductCategoryVariantOptionsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductCategoryVariantOptionsTable::class)]
|
||||
class ProductCategoryVariantOptionsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ class ProductVariantsTableTest extends TestCase
|
|||
* TestInitialize method
|
||||
*
|
||||
* @return void
|
||||
* @uses \App\Model\Table\ProductVariantsTable::initialize()
|
||||
*/
|
||||
public function testInitialize(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
|
|||
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
/**
|
||||
* CakeProducts\Model\Table\ProductsTable Test Case
|
||||
*/
|
||||
#[CoversClass(ProductsTable::class)]
|
||||
class ProductsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue