select options for products + skus, photos form
This commit is contained in:
@@ -61,8 +61,9 @@ class ProductPhotosController extends AppController
|
||||
if ($this->request->is('post')) {
|
||||
if (!$this->request->getData('photo')) {
|
||||
$this->Flash->error('Photo is required. Nothing was uploaded. Please try again.');
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$this->set(compact('productPhoto', 'products'));
|
||||
$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();
|
||||
$this->set(compact('productPhoto', 'productCatalogs', 'productCategory'));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -107,10 +108,9 @@ class ProductPhotosController extends AppController
|
||||
// dd(print_r($productPhoto->getErrors(), true));
|
||||
$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();
|
||||
|
||||
$this->set(compact('productPhoto', 'products', 'productSkus'));
|
||||
$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();
|
||||
$this->set(compact('productPhoto', 'productCatalogs', 'productCategory'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -239,4 +239,18 @@ class ProductSkusController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
$productSkus = $this->getTable()
|
||||
->find('list')
|
||||
->where(['product_id' => $this->request->getQuery('product_id', '-1')])
|
||||
->orderBy(['sku'])
|
||||
->toArray();
|
||||
|
||||
$this->set(compact('productSkus'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,4 +197,22 @@ class ProductsController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Cake\Http\Response|null|void Renders view
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
$productsTable = $this->getTable();
|
||||
$productCategory = $productsTable->ProductCategories->find()
|
||||
->where(['id' => $this->request->getQuery('product_category_id', '-1')])
|
||||
->first();
|
||||
$products = $productsTable
|
||||
->find('list')
|
||||
->where(['product_category_id' => $productCategory->internal_id ?? '-1'])
|
||||
->orderBy(['Products.name'])
|
||||
->toArray();
|
||||
|
||||
$this->set(compact('products'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user