not used to plugin testing - trying to get working but fixtures not working yet
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user