Advertisement
Allnickaretaken

StoreController

Jun 8th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. public function editAction()
  2.     {
  3.         $id = $this->getRequest()->getParam('store_id');
  4.         var_dump($id);
  5.         Mage::register('store_block',Mage::getModel('store/block')->load($id));
  6.         $blockObject = (array)Mage::getSingleton('adminhtml/session')->getBlockObject(true);
  7.         if(count($blockObject)) {
  8.             Mage::registry('store_block')->setData($blockObject);
  9.         }
  10.         $this->loadLayout();
  11.         $this->_addContent($this->getLayout()->createBlock('store/adminhtml_store_edit'));
  12.         $this->renderLayout();
  13.     }
  14.  
  15.     public function saveAction()
  16.     {
  17.         try {
  18.             $id = $this->getRequest()->getParam('store_id');
  19.             $block = Mage::getModel('store/block')->load($id);
  20.             $block
  21.                 ->setData($this->getRequest()->getParams())
  22.                 //->setCreatedAt(Mage::app()->getLocale()->date())
  23.                 ->save();
  24.             if (!$block->getId()) {
  25.                 Mage::getSingleton('adminhtml/session')->addError('Cannot save offline store');
  26.             }
  27.         } catch(Exception $e) {
  28.             Mage::logException($e);
  29.             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
  30.             Mage::getSingleton('adminhtml/session')->setBlockObject($block->getData());
  31.             return  $this->_redirect('*/*/edit',array('store_id'=>$this->getRequest()->getParam('store_id')));
  32.         }
  33.  
  34.         Mage::getSingleton('adminhtml/session')->addSuccess('Offline store was saved successfully!');
  35.  
  36.         $this->_redirect('*/*/'.$this->getRequest()->getParam('back','index'),array('store_id'=>$block->getId()));
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement