from main app code base

This commit is contained in:
2025-03-27 01:11:41 -07:00
parent b17634c08a
commit d9a59fb82b
18 changed files with 131 additions and 1034 deletions

View File

@@ -5,7 +5,6 @@ namespace CakeProducts\Controller;
use Cake\Log\Log;
use CakeProducts\Controller\AppController;
use CakeProducts\Service\InternalCatalogManagerService;
/**
* ExternalProductCatalogs Controller
@@ -46,24 +45,18 @@ class ExternalProductCatalogsController extends AppController
*
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
*/
public function add(InternalCatalogManagerService $catalogManagerService)
public function add()
{
$externalProductCatalog = $this->ExternalProductCatalogs->newEmptyEntity();
if ($this->request->is('post')) {
$postData = $this->request->getData();
if ($this->request->getSession()->read('Auth.User.id')) {
$postData['created_by'] = $this->request->getSession()->read('Auth.User.id');
}
$result = $catalogManagerService->createNewExternalCatalog($externalProductCatalog, $postData);
Log::debug(print_r('$result from createNewExternalCatalog', true));
Log::debug(print_r($result, true));
if ($result['result']) {
$externalProductCatalog = $this->ExternalProductCatalogs->patchEntity($externalProductCatalog, $this->request->getData());
if ($this->ExternalProductCatalogs->save($externalProductCatalog)) {
$this->Flash->success(__('The external product catalog has been saved.'));
return $this->redirect(['action' => 'index']);
}
// Log::debug(print_r('$externalProductCatalog->getErrors() next - failed /add', true));
// Log::debug(print_r($externalProductCatalog->getErrors(), true));
Log::debug(print_r('$externalProductCatalog->getErrors() next - failed /add', true));
Log::debug(print_r($externalProductCatalog->getErrors(), true));
$this->Flash->error(__('The external product catalog could not be saved. Please, try again.'));
}
$productCatalogs = $this->ExternalProductCatalogs->ProductCatalogs->find('list', limit: 200)->all();