stan fixes, code style fixes - all clean
CI / testsuite (mysql, 8.4, ) (push) Successful in 2m51s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Failing after 5m27s
CI / Coding Standard & Static Analysis (push) Failing after 2m34s
CI / testsuite (mysql, 8.2, ) (push) Successful in 6m45s

This commit is contained in:
bs
2026-08-26 01:08:03 -07:00
parent 470a3e76af
commit 7abbb8a5aa
10 changed files with 45 additions and 34 deletions
+1
View File
@@ -8,3 +8,4 @@
/.idea/ /.idea/
tmp tmp
tests/test_app/webroot/images/products/ tests/test_app/webroot/images/products/
tests/test_app/webroot/uploads/
+9 -10
View File
@@ -18,14 +18,12 @@ class ProductCatalogsController extends AppController {
*/ */
public function initialize(): void { public function initialize(): void {
parent::initialize(); // TODO: Change the autogenerated stub parent::initialize(); // TODO: Change the autogenerated stub
// $this->_defaultTable = 'CakeProducts.ProductCatalogs';
// $this->_tableConfigKey = 'CakeProducts.ProductCatalogs.table';
} }
/** /**
* Index method * Index method
* *
* @return \Cake\Http\Response|voidRenders|null view * @return \Cake\Http\Response|null|void Renders view
*/ */
public function index() { public function index() {
$query = $this->ProductCatalogs->find(); $query = $this->ProductCatalogs->find();
@@ -38,8 +36,9 @@ class ProductCatalogsController extends AppController {
* View method * View method
* *
* @param string|null $id Product Catalog id. * @param string|null $id Product Catalog id.
* @throws RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null|void Renders view *
* @return \Cake\Http\Response|null|void Renders view
*/ */
public function view($id = null) { public function view($id = null) {
$contain = ['ProductCategories']; $contain = ['ProductCategories'];
@@ -53,7 +52,7 @@ class ProductCatalogsController extends AppController {
/** /**
* Add method * 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() { public function add() {
$productCatalogsTable = $this->ProductCatalogs; $productCatalogsTable = $this->ProductCatalogs;
@@ -78,8 +77,8 @@ class ProductCatalogsController extends AppController {
* Edit method * Edit method
* *
* @param string|null $id Product Catalog id. * @param string|null $id Product Catalog id.
* @throws RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null|void Redirects on successful edit, renders view otherwise. * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
*/ */
public function edit($id = null) { public function edit($id = null) {
$productCatalogsTable = $this->ProductCatalogs; $productCatalogsTable = $this->ProductCatalogs;
@@ -100,8 +99,8 @@ class ProductCatalogsController extends AppController {
* Delete method * Delete method
* *
* @param string|null $id Product Catalog id. * @param string|null $id Product Catalog id.
* @throws RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null Redirects to index. * @return \Cake\Http\Response|null Redirects to index.
*/ */
public function delete($id = null) { public function delete($id = null) {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
+11 -3
View File
@@ -32,6 +32,7 @@ class ProductPhotosController extends AppController {
* *
* @param string|null $id Product Photo id. * @param string|null $id Product Photo id.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*
* @return \Cake\Http\Response|null|void Renders view * @return \Cake\Http\Response|null|void Renders view
*/ */
public function view($id = null) { public function view($id = null) {
@@ -70,6 +71,9 @@ class ProductPhotosController extends AppController {
'ProductSkus.id' => $this->request->getData('product_sku_id'), 'ProductSkus.id' => $this->request->getData('product_sku_id'),
]) ])
->first(); ->first();
/**
* @var \CakeProducts\Model\Entity\ProductSku|null $productSku
*/
$path = $productSku ? $productSku->product_id . DS . 'skus' . DS . $productSku->id : $path; $path = $productSku ? $productSku->product_id . DS . 'skus' . DS . $productSku->id : $path;
$postData['product_id'] = $productSku->product->id ?? null; $postData['product_id'] = $productSku->product->id ?? null;
@@ -82,6 +86,9 @@ class ProductPhotosController extends AppController {
'Products.id' => $this->request->getData('product_id'), 'Products.id' => $this->request->getData('product_id'),
]) ])
->first(); ->first();
/**
* @var \CakeProducts\Model\Entity\Product|null $product
*/
$path = $product ? $product->id : $path; $path = $product ? $product->id : $path;
$postData['product_category_id'] = $product->product_category->internal_id ?? null; $postData['product_category_id'] = $product->product_category->internal_id ?? null;
@@ -90,7 +97,7 @@ class ProductPhotosController extends AppController {
// @link https://developer.wordpress.org/reference/functions/wp_is_uuid/ // @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}$/'; $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'; $field = preg_match($regex, $categoryId) ? 'ProductCategories.internal_id' : 'ProductCategories.id';
$productCategoryPosted = $this->fetchTable('ProductCategories') $productCategoryPosted = $this->fetchTable('CakeProducts.ProductCategories')
->find() ->find()
->where([ ->where([
$field => $categoryId, $field => $categoryId,
@@ -148,7 +155,8 @@ class ProductPhotosController extends AppController {
* *
* @param string|null $id Product Photo id. * @param string|null $id Product Photo id.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null|void Redirects on successful edit, renders view otherwise. *
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
*/ */
public function edit($id = null) { public function edit($id = null) {
$productPhoto = $this->fetchTable()->get($id, contain: []); $productPhoto = $this->fetchTable()->get($id, contain: []);
@@ -173,7 +181,7 @@ class ProductPhotosController extends AppController {
* *
* @param string|null $id Product Photo id. * @param string|null $id Product Photo id.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
* @return Response|null Redirects to index. * @return \Cake\Http\Response|null Redirects to index.
*/ */
public function delete($id = null) { public function delete($id = null) {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
+5 -2
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace CakeProducts\Controller; namespace CakeProducts\Controller;
use Cake\Log\Log; use Cake\Log\Log;
use CakeProducts\Model\Entity\ProductCategoryVariant;
/** /**
* Products Controller * Products Controller
@@ -77,7 +76,11 @@ class ProductsController extends AppController {
if (!isset($postedProductVariant['enabled']) || !$postedProductVariant['enabled'] || !isset($postedProductVariant['product_category_variant_id'])) { if (!isset($postedProductVariant['enabled']) || !$postedProductVariant['enabled'] || !isset($postedProductVariant['product_category_variant_id'])) {
continue; continue;
} }
$existingVariant = $this->fetchTable('ProductCategoryVariants')->get($postedProductVariant['product_category_variant_id'], contain: ['ProductCategoryVariantOptions']); /**
* @var \CakeProducts\Model\Entity\ProductCategoryVariant $existingVariant
*/
$existingVariant = $this->fetchTable('CakeProducts.ProductCategoryVariants')
->get($postedProductVariant['product_category_variant_id'], contain: ['ProductCategoryVariantOptions']);
$optionsData = []; $optionsData = [];
foreach ($existingVariant->product_category_variant_options as $existingOption) { foreach ($existingVariant->product_category_variant_options as $existingOption) {
$optionsData[] = [ $optionsData[] = [
+2 -2
View File
@@ -15,8 +15,8 @@ use Cake\ORM\Entity;
* @property bool $enabled * @property bool $enabled
* @property bool $is_system_variant * @property bool $is_system_variant
* *
* @property ProductCategory|\Cake\Datasource\EntityInterface $product_category * @property ProductCategory $product_category
* @property ProductCategoryVariantOption[]|\Cake\Datasource\EntityInterface[] $product_category_variant_options * @property ProductCategoryVariantOption[] $product_category_variant_options
*/ */
class ProductCategoryVariant extends Entity { class ProductCategoryVariant extends Entity {