show image on view product photos page, setEntityClass defaulting to all plugin entities
CI / testsuite (mysql, 8.1, ) (push) Failing after 6m12s Details
CI / testsuite (mysql, 8.4, ) (push) Successful in 10m15s Details
CI / testsuite (sqlite, 8.1, prefer-lowest) (push) Failing after 5m57s Details
CI / Coding Standard & Static Analysis (push) Failing after 5m53s Details

This commit is contained in:
Brandon Shipley 2025-09-01 00:46:18 -07:00
parent 155095c25c
commit 8cf8d7cfa0
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
9 changed files with 40 additions and 1 deletions

View File

@ -169,6 +169,8 @@ class ProductPhotosController extends AppController
$fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename; $fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename;
return $this->response->withFile($fullPath); return $this->response->withFile($fullPath, [
'download' => $this->request->getQuery('download', false) === '1'
]);
} }
} }

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface; use Cake\Datasource\ResultSetInterface;
use Cake\ORM\Association\BelongsTo; use Cake\ORM\Association\BelongsTo;
@ -49,6 +50,10 @@ class ProductCategoryAttributeOptionsTable extends Table
$this->setDisplayField('attribute_value'); $this->setDisplayField('attribute_value');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductCategoryAttributeOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryAttributeOption')
);
$this->belongsTo('ProductCategoryAttributes', [ $this->belongsTo('ProductCategoryAttributes', [
'foreignKey' => 'product_category_attribute_id', 'foreignKey' => 'product_category_attribute_id',
'joinType' => 'INNER', 'joinType' => 'INNER',

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use Cake\Database\Type\EnumType; use Cake\Database\Type\EnumType;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface; use Cake\Datasource\ResultSetInterface;
@ -51,6 +52,9 @@ class ProductCategoryAttributesTable extends Table
$this->setDisplayField('name'); $this->setDisplayField('name');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductCategoryAttributes.entity', 'CakeProducts\Model\Entity\ProductCategoryAttribute')
);
$this->belongsTo('ProductCategories', [ $this->belongsTo('ProductCategories', [
'foreignKey' => 'product_category_id', 'foreignKey' => 'product_category_id',
'bindingKey' => 'internal_id', 'bindingKey' => 'internal_id',

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use CakeProducts\Model\Entity\ProductCategoryVariantOption; use CakeProducts\Model\Entity\ProductCategoryVariantOption;
use CakeProducts\Model\Table\ProductCategoryVariantsTable; use CakeProducts\Model\Table\ProductCategoryVariantsTable;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
@ -53,6 +54,9 @@ class ProductCategoryVariantOptionsTable extends Table
$this->setDisplayField('variant_value'); $this->setDisplayField('variant_value');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductCategoryVariantOptions.entity', 'CakeProducts\Model\Entity\ProductCategoryVariantOption')
);
$this->addBehavior('Timestamp'); $this->addBehavior('Timestamp');
$this->belongsTo('ProductCategoryVariants', [ $this->belongsTo('ProductCategoryVariants', [

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use Cake\ORM\Query\SelectQuery; use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker; use Cake\ORM\RulesChecker;
use Cake\ORM\Table; use Cake\ORM\Table;
@ -44,6 +45,10 @@ class ProductCategoryVariantsTable extends Table
$this->setDisplayField('name'); $this->setDisplayField('name');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductCategoryVariants.entity', 'CakeProducts\Model\Entity\ProductCategoryVariant')
);
$this->belongsTo('ProductCategories', [ $this->belongsTo('ProductCategories', [
'foreignKey' => 'product_category_id', 'foreignKey' => 'product_category_id',
'bindingKey' => 'internal_id', 'bindingKey' => 'internal_id',

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface; use Cake\Datasource\ResultSetInterface;
use Cake\ORM\Association\BelongsTo; use Cake\ORM\Association\BelongsTo;
@ -52,6 +53,10 @@ class ProductPhotosTable extends Table
$this->setDisplayField('photo_filename'); $this->setDisplayField('photo_filename');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductPhotos.entity', 'CakeProducts\Model\Entity\ProductPhoto')
);
$this->addBehavior('Timestamp'); $this->addBehavior('Timestamp');
$this->belongsTo('Products', [ $this->belongsTo('Products', [

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use CakeProducts\Model\Table\ProductsTable; use CakeProducts\Model\Table\ProductsTable;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface; use Cake\Datasource\ResultSetInterface;
@ -52,6 +53,10 @@ class ProductSkusTable extends Table
$this->setDisplayField('sku'); $this->setDisplayField('sku');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.ProductSkus.entity', 'CakeProducts\Model\Entity\ProductSku')
);
$this->addBehavior('Timestamp'); $this->addBehavior('Timestamp');
$this->belongsTo('Products', [ $this->belongsTo('Products', [

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace CakeProducts\Model\Table; namespace CakeProducts\Model\Table;
use Cake\Core\Configure;
use Cake\Database\Type\EnumType; use Cake\Database\Type\EnumType;
use Cake\Datasource\EntityInterface; use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface; use Cake\Datasource\ResultSetInterface;
@ -51,6 +52,10 @@ class ProductsTable extends Table
$this->setDisplayField('name'); $this->setDisplayField('name');
$this->setPrimaryKey('id'); $this->setPrimaryKey('id');
$this->setEntityClass(
Configure::read('CakeProducts.Products.entity', 'CakeProducts\Model\Entity\Product')
);
$this->belongsTo('ProductCategories', [ $this->belongsTo('ProductCategories', [
'foreignKey' => 'product_category_id', 'foreignKey' => 'product_category_id',
'bindingKey' => 'internal_id', 'bindingKey' => 'internal_id',

View File

@ -17,6 +17,10 @@
<div class="column column-80"> <div class="column column-80">
<div class="productPhotos view content"> <div class="productPhotos view content">
<h3><?= h($productPhoto->photo_filename) ?></h3> <h3><?= h($productPhoto->photo_filename) ?></h3>
<img src="<?= $this->Url->build([
'action' => 'image',
$productPhoto->id,
]); ?>" alt="<?= $productPhoto->id; ?>"/>
<table> <table>
<tr> <tr>
<th><?= __('Id') ?></th> <th><?= __('Id') ?></th>