SHARE
TWEET

Untitled

a guest Aug 20th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class NewAction extends MagentoBackendAppAction
  2.  {
  3. /**
  4.  * Edit A Contact Page
  5.  *
  6.  * @return MagentoBackendModelViewResultPage|MagentoBackendModelViewResultRedirect
  7.  * @SuppressWarnings(PHPMD.NPathComplexity)
  8.  */
  9. public function execute()
  10. {
  11.     $this->_view->loadLayout();
  12.     $this->_view->renderLayout();
  13.  
  14.     $contactDatas = $this->getRequest()->getParam('contact');
  15.  
  16.  
  17.     if(is_array($contactDatas)) {
  18.         $contact = $this->_objectManager->create(Contact::class);
  19.         $contact->setData($contactDatas)->save();
  20.         $id = $contact->getId();
  21.         $contactt = $this->_objectManager->create(Contactt::class);
  22.         $contactt->setData('con_id', $id);
  23.         $contactt->setData('address', $contactDatas['address']);
  24.         $contactt->setData('zipcode', $contactDatas['zipcode']);
  25.         $contactt->setData('country', $contactDatas['country']);
  26.         $contactt->save();
  27.         if($contact->save()){
  28.              $this->messageManager->addSuccessMessage(__('You saved the data.'));
  29.         }else{
  30.              $this->messageManager->addErrorMessage(__('Data was not saved.'));
  31.         }
  32.         $resultRedirect = $this->resultRedirectFactory->create();
  33.         return $resultRedirect->setPath('*/*/index');
  34.     }
  35. }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top