From 7e646f80dcf1c39bd603cd37b92e86b5d6a7b6ff Mon Sep 17 00:00:00 2001 From: Brandon Shipley Date: Wed, 26 Aug 2026 00:46:31 -0700 Subject: [PATCH] clean up --- ...oductCatalogsProductCatalogsController.php | 8 ++-- .../ProductCategoriesController.php | 33 +++++++------- .../ProductCategoryAttributesController.php | 43 ++++++++----------- .../ProductCategoryVariantsController.php | 27 ++++++------ src/Controller/ProductPhotosController.php | 42 +++++++++--------- src/Controller/ProductSkusController.php | 4 +- src/Controller/ProductVariantsController.php | 35 ++++++++------- src/Controller/ProductsController.php | 34 +++++++-------- ...nalProductCatalogsProductCatalogsTable.php | 16 ++++--- .../Table/ExternalProductCatalogsTable.php | 14 +++--- src/Model/Table/ProductCatalogsTable.php | 16 ++++--- src/Model/Table/ProductCategoriesTable.php | 26 ++++++----- .../ProductCategoryAttributeOptionsTable.php | 16 ++++--- .../Table/ProductCategoryAttributesTable.php | 16 ++++--- .../ProductCategoryVariantOptionsTable.php | 16 ++++--- .../Table/ProductCategoryVariantsTable.php | 17 +++++--- src/Model/Table/ProductPhotosTable.php | 18 +++++--- .../Table/ProductSkuVariantValuesTable.php | 16 ++++--- src/Model/Table/ProductSkusTable.php | 16 ++++--- src/Model/Table/ProductVariantsTable.php | 16 ++++--- src/Model/Table/ProductsTable.php | 16 ++++--- .../ProductPhotosControllerTest.php | 2 + 22 files changed, 246 insertions(+), 201 deletions(-) diff --git a/src/Controller/ExternalProductCatalogsProductCatalogsController.php b/src/Controller/ExternalProductCatalogsProductCatalogsController.php index e4c05e1..536afd0 100644 --- a/src/Controller/ExternalProductCatalogsProductCatalogsController.php +++ b/src/Controller/ExternalProductCatalogsProductCatalogsController.php @@ -13,11 +13,11 @@ class ExternalProductCatalogsProductCatalogsController extends AppController { /** * Add method * - * @return \Cake\Http\Response|voidRedirects|null on successful add, renders view otherwise. + * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { Log::debug('inside external product catalogs product catalogs controller add'); - $productCatalogs = $this->ExternalProductCatalogsProductCatalogs->ProductCatalogs->find('list')->toArray(); + $productCatalogs = $this->fetchTable('ProductCatalogs')->find('list')->toArray(); $this->set(compact('productCatalogs')); } @@ -30,8 +30,8 @@ class ExternalProductCatalogsProductCatalogsController extends AppController { */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $externalProductCatalogProductCatalog = $this->ExternalProductCatalogsProductCatalogs->get($id); - if ($this->ExternalProductCatalogsProductCatalogs->delete($externalProductCatalogProductCatalog)) { + $externalProductCatalogProductCatalog = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($externalProductCatalogProductCatalog)) { $this->Flash->success(__('The customers contact has been deleted.')); } else { $this->Flash->error(__('The customers contact could not be deleted. Please, try again.')); diff --git a/src/Controller/ProductCategoriesController.php b/src/Controller/ProductCategoriesController.php index 850f1fc..d44519a 100644 --- a/src/Controller/ProductCategoriesController.php +++ b/src/Controller/ProductCategoriesController.php @@ -18,8 +18,6 @@ class ProductCategoriesController extends AppController { */ public function initialize(): void { parent::initialize(); // TODO: Change the autogenerated stub -// $this->_defaultTable = 'CakeProducts.ProductCategories'; -// $this->_tableConfigKey = 'CakeProducts.ProductCategories.table'; } /** @@ -52,7 +50,7 @@ class ProductCategoriesController extends AppController { 'PrimaryProductPhotos', ]); - $productCategoryAttributes = $this->ProductCategories->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id); + $productCategoryAttributes = $this->fetchTable('CakeProducts.ProductCategoryAttributes')->getAllCategoryAttributesForCategoryId($productCategory->internal_id) ?? []; $this->set(compact('productCategory', 'productCategoryAttributes')); } @@ -87,8 +85,8 @@ class ProductCategoriesController extends AppController { } $this->Flash->error(__('The product category could not be saved. Please, try again.')); } - $productCatalogs = $productCategoriesTable->ProductCatalogs->find('list', limit: 200)->all(); - $parentProductCategories = $productCategoriesTable->ParentProductCategories->find('treeList', limit: 200)->toArray(); + $productCatalogs = $this->fetchTable('ProductCatalogs')->find('list', limit: 200)->all(); + $parentProductCategories = $this->fetchTable('ProductCategories')->find('list', limit: 200)->all(); $this->set(compact('productCategory', 'productCatalogs', 'parentProductCategories')); } @@ -100,20 +98,21 @@ class ProductCategoriesController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productCategoriesTable = $this->ProductCategories; - $productCategory = $productCategoriesTable->get($id, contain: []); + $productCategoriesTable = $this->fetchTable(); + $productCategory = $this->ProductCategories->get($id, contain: []); if ($this->request->is(['patch', 'post', 'put'])) { $postData = $this->request->getData(); - $productCategory = $productCategoriesTable->patchEntity($productCategory, $postData); - if ($productCategoriesTable->save($productCategory)) { + $productCategory = $this->ProductCategories->patchEntity($productCategory, $postData); + if ($this->ProductCategories->save($productCategory)) { $this->Flash->success(__('The product category has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The product category could not be saved. Please, try again.')); } - $productCatalogs = $productCategoriesTable->ProductCatalogs->find('list', limit: 200)->all(); - $parentProductCategories = $productCategoriesTable->ParentProductCategories->find('list', limit: 200)->all(); + $productCatalogs = $this->fetchTable('ProductCatalogs')->find('list', limit: 200)->all(); + $parentProductCategories = $this->fetchTable('ProductCategories')->find('list', limit: 200)->all(); + $this->set(compact('productCategory', 'productCatalogs', 'parentProductCategories')); } @@ -126,15 +125,14 @@ class ProductCategoriesController extends AppController { */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productCategoriesTable = $this->ProductCategories; - $productCategory = $productCategoriesTable->get($id); + $productCategory = $this->ProductCategories->get($id); // $productCategoriesTable->behaviors()->get('Tree')->setConfig([ // 'scope' => [ // 'product_catalog_id' => $productCategory->product_catalog_id, // ], // ]); - if ($productCategoriesTable->delete($productCategory)) { + if ($this->ProductCategories->delete($productCategory)) { $this->Flash->success(__('The product category has been deleted.')); } else { $this->Flash->error(__('The product category could not be deleted. Please, try again.')); @@ -147,15 +145,14 @@ class ProductCategoriesController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function select() { - $productCategoriesTable = $this->ProductCategories; - $productCategoriesTable->behaviors()->get('Tree')->setConfig([ + $this->ProductCategories->getBehavior('Tree')->setConfig([ 'scope' => [ 'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1), ], ]); $productCategoriesQ = $this->request->getQuery('form', 'product_category') === 'product' ? - $productCategoriesTable->find('treeList', keyPath: 'internal_id', valuePath: 'name') : - $productCategoriesTable->find('treeList'); + $this->ProductCategories->find('treeList', keyPath: 'internal_id', valuePath: 'name') : + $this->ProductCategories->find('treeList'); $productCategories = $productCategoriesQ ->orderBy(['ProductCategories.name']) diff --git a/src/Controller/ProductCategoryAttributesController.php b/src/Controller/ProductCategoryAttributesController.php index b6e588c..64ec179 100644 --- a/src/Controller/ProductCategoryAttributesController.php +++ b/src/Controller/ProductCategoryAttributesController.php @@ -17,8 +17,6 @@ class ProductCategoryAttributesController extends AppController { */ public function initialize(): void { parent::initialize(); // TODO: Change the autogenerated stub -// $this->_defaultTable = 'CakeProducts.ProductCategoryAttributes'; -// $this->_tableConfigKey = 'CakeProducts.ProductCategoryAttributes.table'; } /** @@ -27,7 +25,7 @@ class ProductCategoryAttributesController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function index() { - $query = $this->ProductCategoryAttributes->find() + $query = $this->fetchTable()->find() ->contain(['ProductCategories']); $productCategoryAttributes = $this->paginate($query); @@ -38,11 +36,11 @@ class ProductCategoryAttributesController extends AppController { * View method * * @param string|null $id Product Category Attribute id. - * @throws RecordNotFoundException When record not found. - * @return Response|null|void Renders view + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + * @return \Cake\Http\Response|null|void Renders view */ public function view($id = null) { - $productCategoryAttribute = $this->ProductCategoryAttributes->get($id, contain: [ + $productCategoryAttribute = $this->fetchTable()->get($id, contain: [ 'ProductCategories', 'ProductCategoryAttributeOptions', ]); @@ -56,8 +54,7 @@ class ProductCategoryAttributesController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { - $productCategoryAttributesTable = $this->ProductCategoryAttributes; - $productCategoryAttribute = $productCategoryAttributesTable->newEmptyEntity(); + $productCategoryAttribute = $this->fetchTable()->newEmptyEntity(); if ($this->request->is('post')) { $postData = $this->request->getData(); if ($this->request->getSession()->read('Auth.User.id')) { @@ -70,12 +67,12 @@ class ProductCategoryAttributesController extends AppController { 'ProductCategoryAttributeOptions', ], ]; - $productCategoryAttribute = $productCategoryAttributesTable->patchEntity($productCategoryAttribute, $postData, $saveOptions); + $productCategoryAttribute = $this->fetchTable()->patchEntity($productCategoryAttribute, $postData, $saveOptions); if ($productCategoryAttribute->getErrors()) { Log::debug(print_r('$productCategoryAttribute->getErrors() next - failed to save from create new product category attribute', true)); Log::debug(print_r($productCategoryAttribute->getErrors(), true)); } - if ($productCategoryAttributesTable->save($productCategoryAttribute, $saveOptions)) { + if ($this->fetchTable()->save($productCategoryAttribute, $saveOptions)) { $this->Flash->success(__('The product category attribute has been saved.')); return $this->redirect(['action' => 'index']); @@ -85,7 +82,7 @@ class ProductCategoryAttributesController extends AppController { Log::debug(print_r($productCategoryAttribute->getErrors(), true)); $this->Flash->error(__('The product category attribute could not be saved. Please, try again.')); } - $productCategories = $productCategoryAttributesTable->ProductCategories->find('list', keyField: 'internal_id', valueField: 'name')->all(); + $productCategories = $this->fetchTable()->ProductCategories->find('list', keyField: 'internal_id', valueField: 'name')->all(); $this->set(compact('productCategoryAttribute', 'productCategories')); } @@ -93,12 +90,11 @@ class ProductCategoryAttributesController extends AppController { * Edit method * * @param string|null $id Product Category Attribute id. - * @throws RecordNotFoundException When record not found. - * @return Response|null|void Redirects on successful edit, renders view otherwise. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productCategoryAttributesTable = $this->ProductCategoryAttributes; - $productCategoryAttribute = $productCategoryAttributesTable->get($id, contain: ['ProductCategoryAttributeOptions']); + $productCategoryAttribute = $this->fetchTable()->get($id, contain: ['ProductCategoryAttributeOptions']); if ($this->request->is(['patch', 'post', 'put'])) { $postData = $this->request->getData(); $saveOptions = [ @@ -112,9 +108,9 @@ class ProductCategoryAttributesController extends AppController { // } Log::debug(print_r('$postData', true)); Log::debug(print_r($postData, true)); - $productCategoryAttribute = $productCategoryAttributesTable->patchEntity($productCategoryAttribute, $postData, $saveOptions); + $productCategoryAttribute = $this->fetchTable()->patchEntity($productCategoryAttribute, $postData, $saveOptions); - if ($productCategoryAttributesTable->save($productCategoryAttribute, $saveOptions)) { + if ($this->fetchTable()->save($productCategoryAttribute, $saveOptions)) { $this->Flash->success(__('The product category attribute has been saved.')); return $this->redirect(['action' => 'index']); @@ -124,7 +120,7 @@ class ProductCategoryAttributesController extends AppController { Log::debug(print_r($productCategoryAttribute->getErrors(), true)); $this->Flash->error(__('The product category attribute could not be saved. Please, try again.')); } - $productCategories = $productCategoryAttributesTable->ProductCategories->find('list', limit: 200, keyField: 'internal_id', valueField: 'name')->all(); + $productCategories = $this->fetchTable('ProductCategories')->find('list', limit: 200, keyField: 'internal_id', valueField: 'name')->all(); $this->set(compact('productCategoryAttribute', 'productCategories')); } @@ -132,15 +128,14 @@ class ProductCategoryAttributesController extends AppController { * Delete method * * @param string|null $id Product Category Attribute id. - * @throws RecordNotFoundException When record not found. - * @return Response|null Redirects to index. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + * @return \Cake\Http\Response|null Redirects to index. */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productCategoryAttributesTable = $this->ProductCategoryAttributes; - $productCategoryAttribute = $productCategoryAttributesTable->get($id); - if ($productCategoryAttributesTable->delete($productCategoryAttribute)) { + $productCategoryAttribute = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($productCategoryAttribute)) { $this->Flash->success(__('The product category attribute has been deleted.')); } else { $this->Flash->error(__('The product category attribute could not be deleted. Please, try again.')); @@ -153,7 +148,7 @@ class ProductCategoryAttributesController extends AppController { * @return void */ public function form() { - $productCategories = $this->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1')); + $productCategories = $this->fetchTable()->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1')); $this->set(compact('productCategories')); } diff --git a/src/Controller/ProductCategoryVariantsController.php b/src/Controller/ProductCategoryVariantsController.php index e74b753..fc455cd 100644 --- a/src/Controller/ProductCategoryVariantsController.php +++ b/src/Controller/ProductCategoryVariantsController.php @@ -8,7 +8,7 @@ use Cake\Log\Log; /** * ProductCategoryVariants Controller * - * @property CakeProducts\Model\Table\ProductCategoryVariantsTable $ProductCategoryVariants + * @property \CakeProducts\Model\Table\ProductCategoryVariantsTable $ProductCategoryVariants */ class ProductCategoryVariantsController extends AppController { @@ -17,8 +17,6 @@ class ProductCategoryVariantsController extends AppController { */ public function initialize(): void { parent::initialize(); // TODO: Change the autogenerated stub -// $this->_defaultTable = 'CakeProducts.ProductCategoryVariants'; -// $this->_tableConfigKey = 'CakeProducts.ProductCategoryVariants.table'; } /** @@ -27,7 +25,7 @@ class ProductCategoryVariantsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function index() { - $query = $this->ProductCategoryVariants->find() + $query = $this->fetchTable()->find() ->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']); $productCategoryVariants = $this->paginate($query); @@ -42,7 +40,7 @@ class ProductCategoryVariantsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function view($id = null) { - $productCategoryVariant = $this->ProductCategoryVariants->get($id, contain: [ + $productCategoryVariant = $this->fetchTable()->get($id, contain: [ 'ProductCategories', 'Products', 'ProductCategoryVariantOptions', @@ -56,7 +54,7 @@ class ProductCategoryVariantsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { - $productCategoryVariantsTable = $this->ProductCategoryVariants; + $productCategoryVariantsTable = $this->fetchTable(); $productCategoryVariant = $productCategoryVariantsTable->newEmptyEntity(); if ($this->request->is('post')) { @@ -92,8 +90,7 @@ class ProductCategoryVariantsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productCategoryVariantsTable = $this->ProductCategoryVariants; - $productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []); + $productCategoryVariant = $this->fetchTable()->get($id, contain: []); if ($this->request->is(['patch', 'post', 'put'])) { $postData = $this->request->getData(); // if ($this->request->getSession()->read('Auth.User.id')) { @@ -113,9 +110,9 @@ class ProductCategoryVariantsController extends AppController { 'ProductCategoryVariantOptions', ], ]; - $productCategoryVariant = $productCategoryVariantsTable->patchEntity($productCategoryVariant, $postData, $saveOptions); + $productCategoryVariant = $this->fetchTable()->patchEntity($productCategoryVariant, $postData, $saveOptions); // dd($postData); - if ($productCategoryVariantsTable->save($productCategoryVariant, $saveOptions)) { + if ($this->fetchTable()->save($productCategoryVariant, $saveOptions)) { $this->Flash->success(__('The product category variant has been saved.')); return $this->redirect(['action' => 'index']); @@ -123,8 +120,9 @@ class ProductCategoryVariantsController extends AppController { // dd($productCategoryVariant->getErrors()); $this->Flash->error(__('The product category variant could not be saved. Please, try again.')); } - $productCategories = $productCategoryVariantsTable->ProductCategories->find('list', keyField: 'internal_id', valueField: 'name')->all(); - $products = isset($productCategoryVariant->product_category_id) ? $productCategoryVariantsTable->Products->find('list', limit: 200)->where(['product_category_id' => $productCategoryVariant->product_category_id])->all() : []; + $productCategories = $this->fetchTable('ProductCategories')->find('list', keyField: 'internal_id', valueField: 'name')->all(); + $products = isset($productCategoryVariant->product_category_id) ? $this->fetchTable('Products')->find('list', limit: 200) + ->where(['product_category_id' => $productCategoryVariant->product_category_id])->all() : []; $this->set(compact('productCategoryVariant', 'productCategories', 'products')); } @@ -137,10 +135,9 @@ class ProductCategoryVariantsController extends AppController { */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productCategoryVariantsTable = $this->ProductCategoryVariants; - $productCategoryVariant = $productCategoryVariantsTable->get($id); - if ($productCategoryVariantsTable->delete($productCategoryVariant)) { + $productCategoryVariant = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($productCategoryVariant)) { $this->Flash->success(__('The product category variant has been deleted.')); } else { $this->Flash->error(__('The product category variant could not be deleted. Please, try again.')); diff --git a/src/Controller/ProductPhotosController.php b/src/Controller/ProductPhotosController.php index 1c4b63b..986852a 100644 --- a/src/Controller/ProductPhotosController.php +++ b/src/Controller/ProductPhotosController.php @@ -45,13 +45,14 @@ class ProductPhotosController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { - $productPhotosTable = $this->ProductPhotos; - $productPhoto = $productPhotosTable->newEmptyEntity(); + $productPhoto = $this->fetchTable()->newEmptyEntity(); if ($this->request->is('post')) { +// dd($this->request->getData()); if (!$this->request->getData('photo')) { $this->Flash->error('Photo is required. Nothing was uploaded. Please try again.'); - $productCategory = $productPhoto->product_category_id ? $productPhotosTable->ProductCategories->find()->where(['internal_id' => $productPhoto->product_category_id ?? '-1'])->first() : null; - $productCatalogs = $productPhotosTable->ProductCategories->ProductCatalogs->find('list')->toArray(); + $productCategory = $productPhoto->product_category_id ? $this->fetchTable('CakeProducts.ProductCategories')->find() + ->where(['internal_id' => $productPhoto->product_category_id ?? '-1'])->first() : null; + $productCatalogs = $this->fetchTable('CakeProducts.ProductCatalogs')->find('list')->toArray(); $this->set(compact('productPhoto', 'productCatalogs', 'productCategory')); return; @@ -62,7 +63,7 @@ class ProductPhotosController extends AppController { $baseDir = Configure::readOrFail('CakeProducts.photos.directory'); $path = ''; if ($this->request->getData('product_sku_id')) { - $productSku = $productPhotosTable->ProductSkus + $productSku = $this->fetchTable('CakeProducts.ProductSkus') ->find() ->contain(['Products', 'Products.ProductCategories']) ->where([ @@ -74,7 +75,7 @@ class ProductPhotosController extends AppController { $postData['product_id'] = $productSku->product->id ?? null; $postData['product_category_id'] = $productSku->product->product_category->internal_id ?? null; } else if ($this->request->getData('product_id')) { - $product = $productPhotosTable->Products + $product = $this->fetchTable('CakeProducts.Products') ->find() ->contain(['ProductCategories']) ->where([ @@ -89,7 +90,7 @@ class ProductPhotosController extends AppController { // @link https://developer.wordpress.org/reference/functions/wp_is_uuid/ $regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/'; $field = preg_match($regex, $categoryId) ? 'ProductCategories.internal_id' : 'ProductCategories.id'; - $productCategoryPosted = $productPhotosTable->ProductCategories + $productCategoryPosted = $this->fetchTable('ProductCategories') ->find() ->where([ $field => $categoryId, @@ -127,8 +128,8 @@ class ProductPhotosController extends AppController { $postData['photo_filename'] = $uuid . '.' . $ext; // dd($postData); - $productPhoto = $productPhotosTable->patchEntity($productPhoto, $postData); - if ($productPhotosTable->save($productPhoto)) { + $productPhoto = $this->fetchTable()->patchEntity($productPhoto, $postData); + if ($this->fetchTable()->save($productPhoto)) { $this->Flash->success(__('The product photo has been saved.')); return $this->redirect(['action' => 'index']); @@ -136,8 +137,9 @@ class ProductPhotosController extends AppController { // dd($productPhoto->getErrors()); $this->Flash->error(__('The product photo could not be saved. Please, try again.')); } - $productCategory = $productPhoto->product_category_id ? $productPhotosTable->ProductCategories->find()->where(['internal_id' => $productPhoto->product_category_id ?? '-1'])->first() : null; - $productCatalogs = $productPhotosTable->ProductCategories->ProductCatalogs->find('list')->toArray(); + $productCategory = $productPhoto->product_category_id ? $this->fetchTable('ProductCategories')->find() + ->where(['internal_id' => $productPhoto->product_category_id ?? '-1'])->first() : null; + $productCatalogs = $this->fetchTable('ProductCatalogs')->find('list')->toArray(); $this->set(compact('productPhoto', 'productCatalogs', 'productCategory')); } @@ -149,21 +151,20 @@ class ProductPhotosController extends AppController { * @return Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productPhotosTable = $this->ProductPhotos; - $productPhoto = $productPhotosTable->get($id, contain: []); + $productPhoto = $this->fetchTable()->get($id, contain: []); if ($this->request->is(['patch', 'post', 'put'])) { $postData = $this->request->getData(); - $productPhoto = $productPhotosTable->patchEntity($productPhoto, $postData); - if ($productPhotosTable->save($productPhoto)) { + $productPhoto = $this->fetchTable()->patchEntity($productPhoto, $postData); + if ($this->fetchTable()->save($productPhoto)) { $this->Flash->success(__('The product photo has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The product photo could not be saved. Please, try again.')); } - $products = $productPhotosTable->Products->find('list', limit: 200)->all(); - $productSkus = $productPhotosTable->ProductSkus->find('list', limit: 200)->all(); + $products = $this->fetchTable('Products')->find('list', limit: 200)->all(); + $productSkus = $this->fetchTable('ProductSkus')->find('list', limit: 200)->all(); $this->set(compact('productPhoto', 'products', 'productSkus')); } @@ -176,10 +177,9 @@ class ProductPhotosController extends AppController { */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productPhotosTable = $this->ProductPhotos; - $productPhoto = $productPhotosTable->get($id); - if ($productPhotosTable->delete($productPhoto)) { + $productPhoto = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($productPhoto)) { $this->Flash->success(__('The product photo has been deleted.')); } else { $this->Flash->error(__('The product photo could not be deleted. Please, try again.')); @@ -193,7 +193,7 @@ class ProductPhotosController extends AppController { * @return \Cake\Http\Response */ public function image($id = null) { - $productPhoto = $this->ProductPhotos->get($id); + $productPhoto = $this->fetchTable()->get($id); $fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename; diff --git a/src/Controller/ProductSkusController.php b/src/Controller/ProductSkusController.php index f94a140..ebadf70 100644 --- a/src/Controller/ProductSkusController.php +++ b/src/Controller/ProductSkusController.php @@ -19,8 +19,6 @@ class ProductSkusController extends AppController { */ public function initialize(): void { parent::initialize(); // TODO: Change the autogenerated stub -// $this->_defaultTable = 'CakeProducts.ProductSkus'; -// $this->_tableConfigKey = 'CakeProducts.ProductSkus.table'; } /** @@ -159,7 +157,7 @@ class ProductSkusController extends AppController { if (!$this->ProductSkus->save($productSkuToSave, $saveOptions)) { Log::debug(print_r('$productSkuToSave->getErrors()', true)); Log::debug(print_r($productSkuToSave->getErrors(), true)); - dd($productSkuToSave->getErrors()); +// dd($productSkuToSave->getErrors()); continue; } diff --git a/src/Controller/ProductVariantsController.php b/src/Controller/ProductVariantsController.php index ed86066..7163b64 100644 --- a/src/Controller/ProductVariantsController.php +++ b/src/Controller/ProductVariantsController.php @@ -8,7 +8,7 @@ use Cake\Log\Log; /** * ProductVariants Controller * - * @property CakeProducts\Model\Table\ProductVariantsTable $ProductVariants + * @property \CakeProducts\Model\Table\ProductVariantsTable $ProductVariants */ class ProductVariantsController extends AppController { @@ -18,7 +18,7 @@ class ProductVariantsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function index() { - $query = $this->ProductVariants->find() + $query = $this->fetchTable()->find() ->contain(['ProductCategoryVariants', 'Products']); $productVariants = $this->paginate($query); @@ -33,7 +33,7 @@ class ProductVariantsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function view($id = null) { - $productVariant = $this->ProductVariants->get($id, contain: ['ProductCategoryVariants', 'Products']); + $productVariant = $this->fetchTable()->get($id, contain: ['ProductCategoryVariants', 'Products']); $this->set(compact('productVariant')); } @@ -43,16 +43,19 @@ class ProductVariantsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add($productId) { - $product = $this->ProductVariants->Products->get($productId); - $productVariant = $this->ProductVariants->newEmptyEntity(); + $product = $this->fetchTable()->Products->get($productId); + $productVariant = $this->fetchTable()->newEmptyEntity(); if ($this->request->is('post')) { $saveOptions = []; $postData = $this->request->getData(); - $productCategoryVariant = $this->ProductVariants->ProductCategoryVariants->get($this->request->getData('product_category_variant_id', '-1')); + /** + * @var \CakeProducts\Model\Entity\ProductCategoryVariant $productCategoryVariant + */ + $productCategoryVariant = $this->fetchTable('ProductCategoryVariants')->get($this->request->getData('product_category_variant_id', '-1')); $postData['name'] = $productCategoryVariant->name; $postData['product_id'] = $productId; - $productVariant = $this->ProductVariants->patchEntity($productVariant, $postData); - if ($this->ProductVariants->save($productVariant)) { + $productVariant = $this->fetchTable()->patchEntity($productVariant, $postData); + if ($this->fetchTable()->save($productVariant)) { $this->Flash->success(__('The product variant has been saved.')); return $this->redirect(['action' => 'index']); @@ -62,7 +65,7 @@ class ProductVariantsController extends AppController { Log::debug(print_r($productVariant->getErrors(), true)); $this->Flash->error(__('The product variant could not be saved. Please, try again.')); } - $productCategoryVariants = $this->ProductVariants->ProductCategoryVariants + $productCategoryVariants = $this->fetchTable('ProductCategoryVariants') ->find('list', limit: 200) ->where(['product_category_id' => $product->product_category_id]) ->toArray(); @@ -77,18 +80,18 @@ class ProductVariantsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productVariant = $this->ProductVariants->get($id, contain: []); + $productVariant = $this->fetchTable()->get($id, contain: []); if ($this->request->is(['patch', 'post', 'put'])) { - $productVariant = $this->ProductVariants->patchEntity($productVariant, $this->request->getData()); - if ($this->ProductVariants->save($productVariant)) { + $productVariant = $this->fetchTable()->patchEntity($productVariant, $this->request->getData()); + if ($this->fetchTable()->save($productVariant)) { $this->Flash->success(__('The product variant has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The product variant could not be saved. Please, try again.')); } - $productCategoryVariants = $this->ProductVariants->ProductCategoryVariants->find('list', limit: 200)->all(); - $products = $this->ProductVariants->Products->find('list', limit: 200)->all(); + $productCategoryVariants = $this->fetchTable('ProductCategoryVariants')->find('list', limit: 200)->all(); + $products = $this->fetchTable('Products')->find('list', limit: 200)->all(); $this->set(compact('productVariant', 'productCategoryVariants', 'products')); } @@ -101,8 +104,8 @@ class ProductVariantsController extends AppController { */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productVariant = $this->ProductVariants->get($id); - if ($this->ProductVariants->delete($productVariant)) { + $productVariant = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($productVariant)) { $this->Flash->success(__('The product variant has been deleted.')); } else { $this->Flash->error(__('The product variant could not be deleted. Please, try again.')); diff --git a/src/Controller/ProductsController.php b/src/Controller/ProductsController.php index d076f0f..006f14b 100644 --- a/src/Controller/ProductsController.php +++ b/src/Controller/ProductsController.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace CakeProducts\Controller; use Cake\Log\Log; +use CakeProducts\Model\Entity\ProductCategoryVariant; /** * Products Controller @@ -25,7 +26,7 @@ class ProductsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function index() { - $query = $this->Products->find() + $query = $this->fetchTable()->find() ->contain(['ProductCategories']); $products = $this->paginate($query); @@ -40,7 +41,7 @@ class ProductsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function view($id = null) { - $product = $this->Products->get($id, contain: [ + $product = $this->fetchTable()->get($id, contain: [ 'ProductCategories', 'ProductAttributes', 'ProductAttributes.ProductCategoryAttributes', @@ -60,8 +61,7 @@ class ProductsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { - $productsTable = $this->Products; - $product = $productsTable->newEmptyEntity(); + $product = $this->fetchTable()->newEmptyEntity(); if ($this->request->is('post')) { $postData = $this->request->getData(); $saveOptions = [ @@ -77,13 +77,13 @@ class ProductsController extends AppController { if (!isset($postedProductVariant['enabled']) || !$postedProductVariant['enabled'] || !isset($postedProductVariant['product_category_variant_id'])) { continue; } - $existingVariant = $this->Products->ProductCategories->ProductCategoryVariants->get($postedProductVariant['product_category_variant_id'], contain: ['ProductCategoryVariantOptions']); + $existingVariant = $this->fetchTable('ProductCategoryVariants')->get($postedProductVariant['product_category_variant_id'], contain: ['ProductCategoryVariantOptions']); $optionsData = []; foreach ($existingVariant->product_category_variant_options as $existingOption) { $optionsData[] = [ 'variant_value' => $existingOption->variant_value, 'variant_label' => $existingOption->variant_label ?? null, - 'enabled' => $existingOption->enabled, + 'enabled' => $existingOption->enabled ?? false, ]; } $tmpVariantData = [ @@ -113,8 +113,8 @@ class ProductsController extends AppController { $saveOptions['associated'][] = 'ProductCategoryVariants.ProductCategoryVariantOptions'; $postData['product_category_variants'] = $productVariantsData; } - $product = $productsTable->patchEntity($product, $postData, $saveOptions); - if ($productsTable->save($product, $saveOptions)) { + $product = $this->fetchTable()->patchEntity($product, $postData, $saveOptions); + if ($this->fetchTable()->save($product, $saveOptions)) { $this->Flash->success(__('The product has been saved.')); return $this->redirect(['action' => 'index']); @@ -123,8 +123,10 @@ class ProductsController extends AppController { Log::debug(print_r($product->getErrors(), true)); $this->Flash->error(__('The product could not be saved. Please, try again.')); } - $productCategory = $product->product_category_id ? $productsTable->ProductCategories->find()->where(['internal_id' => $product->product_category_id])->first() : null; - $productCatalogs = $productsTable->ProductCategories->ProductCatalogs->find('list')->toArray(); + $productCategory = $product->product_category_id ? $this->fetchTable('ProductCategories')->find() + ->where(['internal_id' => $product->product_category_id])->first() : null; + $productCatalogs = $this->fetchTable('ProductCatalogs')->find('list')->toArray(); + $this->set(compact('product', 'productCatalogs', 'productCategory')); } @@ -136,7 +138,7 @@ class ProductsController extends AppController { * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. */ public function edit($id = null) { - $productsTable = $this->Products; + $productsTable = $this->fetchTable(); $product = $productsTable->get($id, contain: [ 'ProductAttributes', 'ProductAttributes.ProductCategoryAttributes', @@ -171,9 +173,8 @@ class ProductsController extends AppController { public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); - $productsTable = $this->Products; - $product = $productsTable->get($id); - if ($productsTable->delete($product)) { + $product = $this->fetchTable()->get($id); + if ($this->fetchTable()->delete($product)) { $this->Flash->success(__('The product has been deleted.')); } else { $this->Flash->error(__('The product could not be deleted. Please, try again.')); @@ -186,11 +187,10 @@ class ProductsController extends AppController { * @return \Cake\Http\Response|null|void Renders view */ public function select() { - $productsTable = $this->Products; - $productCategory = $productsTable->ProductCategories->find() + $productCategory = $this->fetchTable()->ProductCategories->find() ->where(['id' => $this->request->getQuery('product_category_id', '-1')]) ->first(); - $products = $productsTable + $products = $this->fetchTable() ->find('list') ->where(['product_category_id' => $productCategory->internal_id ?? '-1']) ->orderBy(['Products.name']) diff --git a/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php b/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php index 29837f0..796778a 100644 --- a/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php +++ b/src/Model/Table/ExternalProductCatalogsProductCatalogsTable.php @@ -18,14 +18,18 @@ use Cake\Validation\Validator; * @property ProductCatalogsTable&\Cake\ORM\Association\BelongsTo $ProductCatalogs * * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEmptyEntity() - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEntity() + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog get() - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog findOrCreate() - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog patchEntity() + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog|false save(\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog saveOrFail() + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog> deleteManyOrFail(iterable $entities, array $options = []) * * @mixin TimestampBehavior */ diff --git a/src/Model/Table/ExternalProductCatalogsTable.php b/src/Model/Table/ExternalProductCatalogsTable.php index d2dc55a..7f1af0c 100644 --- a/src/Model/Table/ExternalProductCatalogsTable.php +++ b/src/Model/Table/ExternalProductCatalogsTable.php @@ -14,14 +14,18 @@ use Cake\Validation\Validator; * @property ProductCatalogsTable&\Cake\ORM\Association\BelongsTo $ProductCatalogs * * @method \CakeProducts\Model\Entity\ExternalProductCatalog newEmptyEntity() - * @method \CakeProducts\Model\Entity\ExternalProductCatalog newEntity() + * @method \CakeProducts\Model\Entity\ExternalProductCatalog newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ExternalProductCatalog> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ExternalProductCatalog get() - * @method \CakeProducts\Model\Entity\ExternalProductCatalog findOrCreate() - * @method \CakeProducts\Model\Entity\ExternalProductCatalog patchEntity() + * @method \CakeProducts\Model\Entity\ExternalProductCatalog get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ExternalProductCatalog findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ExternalProductCatalog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ExternalProductCatalog> patchEntities(iterable $entities, array $data, array $options = []) * @method \CakeProducts\Model\Entity\ExternalProductCatalog|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ExternalProductCatalog saveOrFail() + * @method \CakeProducts\Model\Entity\ExternalProductCatalog saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ExternalProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ExternalProductCatalog> deleteManyOrFail(iterable $entities, array $options = []) * * @mixin \Cake\ORM\Behavior\TimestampBehavior */ diff --git a/src/Model/Table/ProductCatalogsTable.php b/src/Model/Table/ProductCatalogsTable.php index af56248..fdaf3af 100644 --- a/src/Model/Table/ProductCatalogsTable.php +++ b/src/Model/Table/ProductCatalogsTable.php @@ -12,14 +12,18 @@ use Cake\Validation\Validator; * ProductCatalogs Model * * @method \CakeProducts\Model\Entity\ProductCatalog newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCatalog newEntity() + * @method \CakeProducts\Model\Entity\ProductCatalog newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCatalog> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCatalog get() - * @method \CakeProducts\Model\Entity\ProductCatalog findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCatalog patchEntity() + * @method \CakeProducts\Model\Entity\ProductCatalog get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCatalog findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCatalog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCatalog> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCatalog|false save(\CakeProducts\Model\Entity\ProductCatalog|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCatalog saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCatalog|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCatalog saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCatalog>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCatalog> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCatalog>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCatalog>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCatalog> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductCatalogsTable extends Table { diff --git a/src/Model/Table/ProductCategoriesTable.php b/src/Model/Table/ProductCategoriesTable.php index 9858d7f..199daab 100644 --- a/src/Model/Table/ProductCategoriesTable.php +++ b/src/Model/Table/ProductCategoriesTable.php @@ -19,13 +19,17 @@ use CakeProducts\Model\Enum\ProductProductTypeId; * @property ProductCategoriesTable&\Cake\ORM\Association\HasMany $ChildProductCategories * * @method \CakeProducts\Model\Entity\ProductCategory newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCategory newEntity() + * @method \CakeProducts\Model\Entity\ProductCategory newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategory> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategory get() - * @method \CakeProducts\Model\Entity\ProductCategory findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCategory patchEntity() + * @method \CakeProducts\Model\Entity\ProductCategory get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCategory findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategory patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategory> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategory saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCategory saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategory>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategory>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategory>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategory> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategory>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategory>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategory>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategory> deleteManyOrFail(iterable $entities, array $options = []) * * @mixin \Cake\ORM\Behavior\TreeBehavior */ @@ -59,9 +63,9 @@ class ProductCategoriesTable extends Table { ]); $this->belongsTo('ProductCatalogs', [ + 'className' => 'CakeProducts.ProductCatalogs', 'foreignKey' => 'product_catalog_id', 'joinType' => 'INNER', - 'className' => 'CakeProducts.ProductCatalogs', ]); $this->belongsTo('ParentProductCategories', [ 'className' => 'CakeProducts.ProductCategories', @@ -74,38 +78,38 @@ class ProductCategoriesTable extends Table { 'cascadeCallbacks' => true, ]); $this->hasMany('ProductCategoryAttributes', [ + 'className' => 'CakeProducts.ProductCategoryAttributes', 'foreignKey' => 'product_category_id', 'bindingKey' => 'internal_id', - 'className' => 'CakeProducts.ProductCategoryAttributes', 'dependent' => true, 'cascadeCallbacks' => true, ]); $this->hasMany('ProductCategoryVariants', [ + 'className' => 'CakeProducts.ProductCategoryVariants', 'foreignKey' => 'product_category_id', 'bindingKey' => 'internal_id', - 'className' => 'CakeProducts.ProductCategoryVariants', 'dependent' => true, 'cascadeCallbacks' => true, ]); $this->hasMany('Products', [ + 'className' => 'CakeProducts.Products', 'foreignKey' => 'product_category_id', 'bindingKey' => 'internal_id', - 'className' => 'CakeProducts.Products', 'dependent' => true, 'cascadeCallbacks' => true, ]); $this->hasMany('ProductPhotos', [ + 'className' => 'CakeProducts.ProductPhotos', 'foreignKey' => 'product_category_id', 'bindingKey' => 'internal_id', - 'className' => 'CakeProducts.ProductPhotos', 'dependent' => true, 'cascadeCallbacks' => true, ]); $this->hasOne('PrimaryProductPhotos', [ + 'className' => 'CakeProducts.ProductPhotos', 'foreignKey' => 'product_category_id', 'bindingKey' => 'internal_id', 'conditions' => ['PrimaryProductPhotos.primary_category_photo' => true], - 'className' => 'CakeProducts.ProductPhotos', 'dependent' => true, ]); diff --git a/src/Model/Table/ProductCategoryAttributeOptionsTable.php b/src/Model/Table/ProductCategoryAttributeOptionsTable.php index ca123f6..5ea59e3 100644 --- a/src/Model/Table/ProductCategoryAttributeOptionsTable.php +++ b/src/Model/Table/ProductCategoryAttributeOptionsTable.php @@ -14,14 +14,18 @@ use Cake\Validation\Validator; * @property ProductCategoryAttributesTable&\Cake\ORM\Association\BelongsTo $ProductCategoryAttributes * * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption newEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryAttributeOption> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption get() - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption patchEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryAttributeOption> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption|false save(\CakeProducts\Model\Entity\ProductCategoryAttributeOption|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryAttributeOption saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttributeOption> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttributeOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttributeOption> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductCategoryAttributeOptionsTable extends Table { diff --git a/src/Model/Table/ProductCategoryAttributesTable.php b/src/Model/Table/ProductCategoryAttributesTable.php index 4dac6be..b39d722 100644 --- a/src/Model/Table/ProductCategoryAttributesTable.php +++ b/src/Model/Table/ProductCategoryAttributesTable.php @@ -17,14 +17,18 @@ use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId; * @property ProductCategoriesTable&\Cake\ORM\Association\BelongsTo $ProductCategories * * @method \CakeProducts\Model\Entity\ProductCategoryAttribute newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute newEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryAttribute> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute get() - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute patchEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryAttribute> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute|false save(\CakeProducts\Model\Entity\ProductCategoryAttribute|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryAttribute saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryAttribute saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttribute>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttribute>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttribute>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttribute> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttribute>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttribute>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryAttribute>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryAttribute> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductCategoryAttributesTable extends Table { diff --git a/src/Model/Table/ProductCategoryVariantOptionsTable.php b/src/Model/Table/ProductCategoryVariantOptionsTable.php index a78c061..18fc999 100644 --- a/src/Model/Table/ProductCategoryVariantOptionsTable.php +++ b/src/Model/Table/ProductCategoryVariantOptionsTable.php @@ -14,14 +14,18 @@ use Cake\Validation\Validator; * @property ProductCategoryVariantsTable&\Cake\ORM\Association\BelongsTo $ProductCategoryVariants * * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption newEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryVariantOption> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption get() - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption patchEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryVariantOption> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption|false save(\CakeProducts\Model\Entity\ProductCategoryVariantOption|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryVariantOption saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariantOption> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariantOption>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariantOption> deleteManyOrFail(iterable $entities, array $options = []) * * @mixin \Cake\ORM\Behavior\TimestampBehavior */ diff --git a/src/Model/Table/ProductCategoryVariantsTable.php b/src/Model/Table/ProductCategoryVariantsTable.php index 20b6e50..bfeb8a8 100644 --- a/src/Model/Table/ProductCategoryVariantsTable.php +++ b/src/Model/Table/ProductCategoryVariantsTable.php @@ -16,14 +16,19 @@ use Cake\Validation\Validator; * @property ProductsTable&\Cake\ORM\Association\BelongsTo $Products * * @method \CakeProducts\Model\Entity\ProductCategoryVariant newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductCategoryVariant newEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryVariant newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryVariant> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariant get() - * @method \CakeProducts\Model\Entity\ProductCategoryVariant findOrCreate() - * @method \CakeProducts\Model\Entity\ProductCategoryVariant patchEntity() + * @method \CakeProducts\Model\Entity\ProductCategoryVariant get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductCategoryVariant findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryVariant patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductCategoryVariant> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariant|false save(\CakeProducts\Model\Entity\ProductCategoryVariant|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductCategoryVariant saveOrFail() + * @method \CakeProducts\Model\Entity\ProductCategoryVariant|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductCategoryVariant saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariant>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariant> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariant>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductCategoryVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductCategoryVariant> deleteManyOrFail(iterable $entities, array $options = []) + * / */ class ProductCategoryVariantsTable extends Table { diff --git a/src/Model/Table/ProductPhotosTable.php b/src/Model/Table/ProductPhotosTable.php index 3b3931f..01d9ddc 100644 --- a/src/Model/Table/ProductPhotosTable.php +++ b/src/Model/Table/ProductPhotosTable.php @@ -15,15 +15,19 @@ use Cake\Validation\Validator; * @property ProductSkusTable&\Cake\ORM\Association\BelongsTo $ProductSkus * * @method \CakeProducts\Model\Entity\ProductPhoto newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductPhoto newEntity() + * @method \CakeProducts\Model\Entity\ProductPhoto newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductPhoto> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductPhoto get() - * @method \CakeProducts\Model\Entity\ProductPhoto findOrCreate() - * @method \CakeProducts\Model\Entity\ProductPhoto patchEntity() + * @method \CakeProducts\Model\Entity\ProductPhoto get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductPhoto findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductPhoto patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductPhoto> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductPhoto|false save(\CakeProducts\Model\Entity\ProductPhoto|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductPhoto saveOrFail() - * + * @method \CakeProducts\Model\Entity\ProductPhoto|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductPhoto saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductPhoto>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductPhoto>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductPhoto>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductPhoto> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductPhoto>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductPhoto>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductPhoto>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductPhoto> deleteManyOrFail(iterable $entities, array $options = []) + * * @mixin \Cake\ORM\Behavior\TimestampBehavior */ class ProductPhotosTable extends Table { diff --git a/src/Model/Table/ProductSkuVariantValuesTable.php b/src/Model/Table/ProductSkuVariantValuesTable.php index 1b00214..43febef 100644 --- a/src/Model/Table/ProductSkuVariantValuesTable.php +++ b/src/Model/Table/ProductSkuVariantValuesTable.php @@ -15,14 +15,18 @@ use Cake\Validation\Validator; * @property ProductCategoryVariantOptionsTable&\Cake\ORM\Association\BelongsTo $ProductCategoryVariantOptions * * @method \CakeProducts\Model\Entity\ProductSkuVariantValue newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue newEntity() + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductSkuVariantValue> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue get() - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue findOrCreate() - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue patchEntity() + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductSkuVariantValue> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue|false save(\CakeProducts\Model\Entity\ProductSkuVariantValue|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSkuVariantValue saveOrFail() + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductSkuVariantValue saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSkuVariantValue>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSkuVariantValue>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSkuVariantValue>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSkuVariantValue> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSkuVariantValue>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSkuVariantValue>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSkuVariantValue>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSkuVariantValue> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductSkuVariantValuesTable extends Table { diff --git a/src/Model/Table/ProductSkusTable.php b/src/Model/Table/ProductSkusTable.php index 34898bf..3149bab 100644 --- a/src/Model/Table/ProductSkusTable.php +++ b/src/Model/Table/ProductSkusTable.php @@ -14,14 +14,18 @@ use Cake\Validation\Validator; * @property ProductsTable&\Cake\ORM\Association\BelongsTo $Products * * @method \CakeProducts\Model\Entity\ProductSku newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductSku newEntity() + * @method \CakeProducts\Model\Entity\ProductSku newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductSku> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSku get() - * @method \CakeProducts\Model\Entity\ProductSku findOrCreate() - * @method \CakeProducts\Model\Entity\ProductSku patchEntity() + * @method \CakeProducts\Model\Entity\ProductSku get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductSku findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductSku patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductSku> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSku|false save(\CakeProducts\Model\Entity\ProductSku|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductSku saveOrFail() + * @method \CakeProducts\Model\Entity\ProductSku|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductSku saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSku>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSku>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSku>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSku> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSku>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSku>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductSku>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductSku> deleteManyOrFail(iterable $entities, array $options = []) * * @mixin \Cake\ORM\Behavior\TimestampBehavior */ diff --git a/src/Model/Table/ProductVariantsTable.php b/src/Model/Table/ProductVariantsTable.php index 16cccfc..b06cef6 100644 --- a/src/Model/Table/ProductVariantsTable.php +++ b/src/Model/Table/ProductVariantsTable.php @@ -14,14 +14,18 @@ use Cake\Validation\Validator; * @property ProductsTable&\Cake\ORM\Association\BelongsTo $Products * * @method \CakeProducts\Model\Entity\ProductVariant newEmptyEntity() - * @method \CakeProducts\Model\Entity\ProductVariant newEntity() + * @method \CakeProducts\Model\Entity\ProductVariant newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductVariant> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductVariant get() - * @method \CakeProducts\Model\Entity\ProductVariant findOrCreate() - * @method \CakeProducts\Model\Entity\ProductVariant patchEntity() + * @method \CakeProducts\Model\Entity\ProductVariant get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\ProductVariant findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\ProductVariant patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\ProductVariant> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\ProductVariant|false save(\CakeProducts\Model\Entity\ProductVariant|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\ProductVariant saveOrFail() + * @method \CakeProducts\Model\Entity\ProductVariant|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\ProductVariant saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductVariant>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductVariant> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductVariant>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\ProductVariant>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\ProductVariant> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductVariantsTable extends Table { diff --git a/src/Model/Table/ProductsTable.php b/src/Model/Table/ProductsTable.php index 2cc424b..a2c4321 100644 --- a/src/Model/Table/ProductsTable.php +++ b/src/Model/Table/ProductsTable.php @@ -16,14 +16,18 @@ use CakeProducts\Model\Enum\ProductProductTypeId; * @property ProductCategoriesTable&\Cake\ORM\Association\BelongsTo $ProductCategories * * @method \CakeProducts\Model\Entity\Product newEmptyEntity() - * @method \CakeProducts\Model\Entity\Product newEntity() + * @method \CakeProducts\Model\Entity\Product newEntity(array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\Product> newEntities(array $data, array $options = []) - * @method \CakeProducts\Model\Entity\Product get() - * @method \CakeProducts\Model\Entity\Product findOrCreate() - * @method \CakeProducts\Model\Entity\Product patchEntity() + * @method \CakeProducts\Model\Entity\Product get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) + * @method \CakeProducts\Model\Entity\Product findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \CakeProducts\Model\Entity\Product patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\CakeProducts\Model\Entity\Product> patchEntities(iterable $entities, array $data, array $options = []) - * @method \CakeProducts\Model\Entity\Product|false save(\CakeProducts\Model\Entity\Product|\Cake\Datasource\EntityInterface $entity, array $options = []) - * @method \CakeProducts\Model\Entity\Product saveOrFail() + * @method \CakeProducts\Model\Entity\Product|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method \CakeProducts\Model\Entity\Product saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\Product>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\Product>|false saveMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\Product>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\Product> saveManyOrFail(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\Product>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\Product>|false deleteMany(iterable $entities, array $options = []) + * @method iterable<\CakeProducts\Model\Entity\Product>|\Cake\Datasource\ResultSetInterface<\CakeProducts\Model\Entity\Product> deleteManyOrFail(iterable $entities, array $options = []) */ class ProductsTable extends Table { diff --git a/tests/TestCase/Controller/ProductPhotosControllerTest.php b/tests/TestCase/Controller/ProductPhotosControllerTest.php index 414fe39..b16abc0 100644 --- a/tests/TestCase/Controller/ProductPhotosControllerTest.php +++ b/tests/TestCase/Controller/ProductPhotosControllerTest.php @@ -178,6 +178,8 @@ class ProductPhotosControllerTest extends BaseControllerTest { 'photo' => $image, 'enabled' => 1, ]; +// dd($data); + $this->post($url, $data); // dd($this->_response); $this->assertResponseCode(302);