not used to plugin testing - trying to get working but fixtures not working yet

This commit is contained in:
2025-03-26 00:07:05 -07:00
parent 23147fc574
commit b17634c08a
21 changed files with 628 additions and 58 deletions

View File

@@ -5,6 +5,7 @@ namespace CakeProducts\Controller;
use Cake\Log\Log;
use CakeProducts\Controller\AppController;
use CakeProducts\Service\InternalCatalogManagerService;
/**
* ExternalProductCatalogs Controller
@@ -45,18 +46,24 @@ class ExternalProductCatalogsController extends AppController
*
* @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
*/
public function add()
public function add(InternalCatalogManagerService $catalogManagerService)
{
$externalProductCatalog = $this->ExternalProductCatalogs->newEmptyEntity();
if ($this->request->is('post')) {
$externalProductCatalog = $this->ExternalProductCatalogs->patchEntity($externalProductCatalog, $this->request->getData());
if ($this->ExternalProductCatalogs->save($externalProductCatalog)) {
$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']) {
$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();