stan fixes, code style fixes - all clean
This commit is contained in:
@@ -8,3 +8,4 @@
|
||||
/.idea/
|
||||
tmp
|
||||
tests/test_app/webroot/images/products/
|
||||
tests/test_app/webroot/uploads/
|
||||
|
||||
@@ -18,14 +18,12 @@ class ProductCatalogsController extends AppController {
|
||||
*/
|
||||
public function initialize(): void {
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
// $this->_defaultTable = 'CakeProducts.ProductCatalogs';
|
||||
// $this->_tableConfigKey = 'CakeProducts.ProductCatalogs.table';
|
||||
}
|
||||
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return \Cake\Http\Response|voidRenders|null view
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function index() {
|
||||
$query = $this->ProductCatalogs->find();
|
||||
@@ -38,8 +36,9 @@ class ProductCatalogsController extends AppController {
|
||||
* View method
|
||||
*
|
||||
* @param string|null $id Product Catalog 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) {
|
||||
$contain = ['ProductCategories'];
|
||||
@@ -53,7 +52,7 @@ class ProductCatalogsController 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() {
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
@@ -78,8 +77,8 @@ class ProductCatalogsController extends AppController {
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Catalog 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) {
|
||||
$productCatalogsTable = $this->ProductCatalogs;
|
||||
@@ -100,8 +99,8 @@ class ProductCatalogsController extends AppController {
|
||||
* Delete method
|
||||
*
|
||||
* @param string|null $id Product Catalog 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']);
|
||||
|
||||
@@ -32,6 +32,7 @@ class ProductPhotosController extends AppController {
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
|
||||
*
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function view($id = null) {
|
||||
@@ -70,6 +71,9 @@ class ProductPhotosController extends AppController {
|
||||
'ProductSkus.id' => $this->request->getData('product_sku_id'),
|
||||
])
|
||||
->first();
|
||||
/**
|
||||
* @var \CakeProducts\Model\Entity\ProductSku|null $productSku
|
||||
*/
|
||||
$path = $productSku ? $productSku->product_id . DS . 'skus' . DS . $productSku->id : $path;
|
||||
|
||||
$postData['product_id'] = $productSku->product->id ?? null;
|
||||
@@ -82,6 +86,9 @@ class ProductPhotosController extends AppController {
|
||||
'Products.id' => $this->request->getData('product_id'),
|
||||
])
|
||||
->first();
|
||||
/**
|
||||
* @var \CakeProducts\Model\Entity\Product|null $product
|
||||
*/
|
||||
$path = $product ? $product->id : $path;
|
||||
$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/
|
||||
$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 = $this->fetchTable('ProductCategories')
|
||||
$productCategoryPosted = $this->fetchTable('CakeProducts.ProductCategories')
|
||||
->find()
|
||||
->where([
|
||||
$field => $categoryId,
|
||||
@@ -148,7 +155,8 @@ class ProductPhotosController extends AppController {
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @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) {
|
||||
$productPhoto = $this->fetchTable()->get($id, contain: []);
|
||||
@@ -173,7 +181,7 @@ class ProductPhotosController extends AppController {
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
* @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) {
|
||||
$this->request->allowMethod(['post', 'delete']);
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
namespace CakeProducts\Controller;
|
||||
|
||||
use Cake\Log\Log;
|
||||
use CakeProducts\Model\Entity\ProductCategoryVariant;
|
||||
|
||||
/**
|
||||
* Products Controller
|
||||
@@ -77,7 +76,11 @@ class ProductsController extends AppController {
|
||||
if (!isset($postedProductVariant['enabled']) || !$postedProductVariant['enabled'] || !isset($postedProductVariant['product_category_variant_id'])) {
|
||||
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 = [];
|
||||
foreach ($existingVariant->product_category_variant_options as $existingOption) {
|
||||
$optionsData[] = [
|
||||
|
||||
@@ -15,8 +15,8 @@ use Cake\ORM\Entity;
|
||||
* @property bool $enabled
|
||||
* @property bool $is_system_variant
|
||||
*
|
||||
* @property ProductCategory|\Cake\Datasource\EntityInterface $product_category
|
||||
* @property ProductCategoryVariantOption[]|\Cake\Datasource\EntityInterface[] $product_category_variant_options
|
||||
* @property ProductCategory $product_category
|
||||
* @property ProductCategoryVariantOption[] $product_category_variant_options
|
||||
*/
|
||||
class ProductCategoryVariant extends Entity {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user