get product skus table via product photos in product photos controller
This commit is contained in:
parent
b9bf47f385
commit
803e161a9a
|
@ -104,7 +104,7 @@ class ProductPhotosController extends AppController
|
|||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
|
||||
$productSkus = $productPhotosTable->ProductSkus->find('list', limit: 200)->all();
|
||||
|
||||
$this->set(compact('productPhoto', 'products', 'productSkus'));
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class ProductPhotosController extends AppController
|
|||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$productSkus = $productPhotosTable->Products->ProductSkus->find('list', limit: 200)->all();
|
||||
$productSkus = $productPhotosTable->ProductSkus->find('list', limit: 200)->all();
|
||||
$this->set(compact('productPhoto', 'products', 'productSkus'));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use Psr\SimpleCache\CacheInterface;
|
|||
* ProductPhotos Model
|
||||
*
|
||||
* @property ProductsTable&BelongsTo $Products
|
||||
* @property ProductSkusTable&BelongsTo $ProductSkus
|
||||
*
|
||||
* @method ProductPhoto newEmptyEntity()
|
||||
* @method ProductPhoto newEntity(array $data, array $options = [])
|
||||
|
|
|
@ -71,6 +71,13 @@ class ProductsTable extends Table
|
|||
'cascadeCallbacks' => true,
|
||||
]);
|
||||
|
||||
// $this->hasMany('ProductSkus', [
|
||||
// 'foreignKey' => 'product_id',
|
||||
// 'className' => 'CakeProducts.ProductSkus',
|
||||
// 'dependent' => true,
|
||||
// 'cascadeCallbacks' => true,
|
||||
// ]);
|
||||
|
||||
$this->getSchema()->setColumnType('product_type_id', EnumType::from(ProductProductTypeId::class));
|
||||
|
||||
$this->addBehavior('Muffin/Trash.Trash');
|
||||
|
|
|
@ -7,6 +7,7 @@ use Cake\Core\Configure;
|
|||
use Cake\ORM\Table;
|
||||
use CakeProducts\Controller\ProductPhotosController;
|
||||
use CakeProducts\Model\Table\ProductPhotosTable;
|
||||
use CakeProducts\Model\Table\ProductsTable;
|
||||
use FilesystemIterator;
|
||||
use Laminas\Diactoros\UploadedFile;
|
||||
use PHPUnit\Exception;
|
||||
|
@ -47,7 +48,8 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
|||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->ProductPhotos = $this->getTableLocator()->get('ProductPhotos');
|
||||
$config = $this->getTableLocator()->exists('ProductPhotos') ? [] : ['className' => ProductPhotosTable::class];
|
||||
$this->ProductPhotos = $this->getTableLocator()->get('ProductPhotos', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue