Public Member Functions | |
indexAction () | |
newWebsiteAction () | |
newGroupAction () | |
newStoreAction () | |
editWebsiteAction () | |
editGroupAction () | |
editStoreAction () | |
saveAction () | |
deleteWebsiteAction () | |
deleteGroupAction () | |
deleteStoreAction () | |
deleteWebsitePostAction () | |
deleteGroupPostAction () | |
deleteStorePostAction () | |
Protected Member Functions | |
_initAction () | |
_isAllowed () | |
_backupDatabase ($failPath, $arguments=array()) | |
_addDeletionNotice ($typeTitle) |
Definition at line 34 of file StoreController.php.
_addDeletionNotice | ( | $ | typeTitle | ) | [protected] |
Add notification on deleting store / store view / website
string | $typeTitle |
Definition at line 465 of file StoreController.php.
00466 { 00467 $this->_getSession()->addNotice( 00468 Mage::helper('core')->__('Deleting a %1$s will not delete the information associated with the %1$s (e.g. categories, products, etc.), but the %1$s will not be able to be restored. It is suggested that you create a database backup before deleting the %1$s.', $typeTitle) 00469 ); 00470 return $this; 00471 }
_backupDatabase | ( | $ | failPath, | |
$ | arguments = array() | |||
) | [protected] |
Backup database
string | $failPath redirect path if backup failed | |
array | $arguments |
Definition at line 431 of file StoreController.php.
00432 { 00433 if (! $this->getRequest()->getParam('create_backup')) { 00434 return $this; 00435 } 00436 try { 00437 $backupDb = Mage::getModel('backup/db'); 00438 $backup = Mage::getModel('backup/backup') 00439 ->setTime(time()) 00440 ->setType('db') 00441 ->setPath(Mage::getBaseDir('var') . DS . 'backups'); 00442 00443 $backupDb->createBackup($backup); 00444 $this->_getSession()->addSuccess(Mage::helper('backup')->__('Database was successfuly backed up.')); 00445 } 00446 catch (Mage_Core_Exception $e) { 00447 $this->_getSession()->addError($e->getMessage()); 00448 $this->_redirect($failPath, $arguments); 00449 return ; 00450 } 00451 catch (Exception $e) { 00452 $this->_getSession()->addException($e, Mage::helper('backup')->__('Unable to create backup. Please, try again later.')); 00453 $this->_redirect($failPath, $arguments); 00454 return ; 00455 } 00456 return $this; 00457 }
_initAction | ( | ) | [protected] |
Init actions
Definition at line 42 of file StoreController.php.
00043 { 00044 // load layout, set active menu and breadcrumbs 00045 $this->loadLayout() 00046 ->_setActiveMenu('system/store') 00047 ->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System')) 00048 ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Stores'), Mage::helper('adminhtml')->__('Manage Stores')) 00049 ; 00050 return $this; 00051 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 419 of file StoreController.php.
00420 { 00421 return Mage::getSingleton('admin/session')->isAllowed('system/store'); 00422 }
deleteGroupAction | ( | ) |
Definition at line 259 of file StoreController.php.
00260 { 00261 $session = $this->_getSession(); 00262 $itemId = $this->getRequest()->getParam('item_id', null); 00263 if (!$model = Mage::getModel('core/store_group')->load($itemId)) { 00264 $session->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00265 $this->_redirect('*/*/'); 00266 return ; 00267 } 00268 if (!$model->isCanDelete()) { 00269 $session->addError(Mage::helper('core')->__('This store cannot be deleted')); 00270 $this->_redirect('*/*/editGroup', array('group_id' => $itemId)); 00271 return ; 00272 } 00273 00274 $this->_addDeletionNotice('store'); 00275 00276 $this->_initAction() 00277 ->_addBreadcrumb(Mage::helper('core')->__('Delete Store'), Mage::helper('core')->__('Delete Store')) 00278 ->_addContent($this->getLayout()->createBlock('adminhtml/system_store_delete') 00279 ->setFormActionUrl($this->getUrl('*/*/deleteGroupPost')) 00280 ->setBackUrl($this->getUrl('*/*/editGroup', array('group_id' => $itemId))) 00281 ->setStoreTypeTitle(Mage::helper('core')->__('Store')) 00282 ->setDataObject($model) 00283 ) 00284 ->renderLayout(); 00285 }
deleteGroupPostAction | ( | ) |
Definition at line 348 of file StoreController.php.
00349 { 00350 $itemId = $this->getRequest()->getParam('item_id'); 00351 00352 if (!$model = Mage::getModel('core/store_group')->load($itemId)) { 00353 $this->_getSession()->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00354 $this->_redirect('*/*/'); 00355 return ; 00356 } 00357 if (!$model->isCanDelete()) { 00358 $this->_getSession()->addError(Mage::helper('core')->__('This store cannot be deleted.')); 00359 $this->_redirect('*/*/editGroup', array('group_id' => $model->getId())); 00360 return ; 00361 } 00362 00363 $this->_backupDatabase('*/*/editGroup', array('group_id' => $itemId)); 00364 00365 try { 00366 $model->delete(); 00367 $this->_getSession()->addSuccess(Mage::helper('core')->__('Store was successfully deleted.')); 00368 $this->_redirect('*/*/'); 00369 return ; 00370 } 00371 catch (Mage_Core_Exception $e) { 00372 $this->_getSession()->addError($e->getMessage()); 00373 } 00374 catch (Exception $e) { 00375 $this->_getSession()->addException($e, Mage::helper('core')->__('Unable to delete store. Please, try again later.')); 00376 } 00377 $this->_redirect('*/*/editGroup', array('group_id' => $itemId)); 00378 }
deleteStoreAction | ( | ) |
Definition at line 287 of file StoreController.php.
00288 { 00289 00290 $session = $this->_getSession(); 00291 $itemId = $this->getRequest()->getParam('item_id', null); 00292 if (!$model = Mage::getModel('core/store')->load($itemId)) { 00293 $session->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00294 $this->_redirect('*/*/'); 00295 return ; 00296 } 00297 if (!$model->isCanDelete()) { 00298 $session->addError(Mage::helper('core')->__('This store view cannot be deleted')); 00299 $this->_redirect('*/*/editStore', array('store_id' => $itemId)); 00300 return ; 00301 } 00302 00303 $this->_addDeletionNotice('store view');; 00304 00305 $this->_initAction() 00306 ->_addBreadcrumb(Mage::helper('core')->__('Delete Store View'), Mage::helper('core')->__('Delete Store View')) 00307 ->_addContent($this->getLayout()->createBlock('adminhtml/system_store_delete') 00308 ->setFormActionUrl($this->getUrl('*/*/deleteStorePost')) 00309 ->setBackUrl($this->getUrl('*/*/editStore', array('store_id' => $itemId))) 00310 ->setStoreTypeTitle(Mage::helper('core')->__('Store View')) 00311 ->setDataObject($model) 00312 ) 00313 ->renderLayout(); 00314 }
deleteStorePostAction | ( | ) |
Delete store view post action
Definition at line 384 of file StoreController.php.
00385 { 00386 $itemId = $this->getRequest()->getParam('item_id'); 00387 00388 if (!$model = Mage::getModel('core/store')->load($itemId)) { 00389 $this->_getSession()->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00390 $this->_redirect('*/*/'); 00391 return ; 00392 } 00393 if (!$model->isCanDelete()) { 00394 $this->_getSession()->addError(Mage::helper('core')->__('This store view cannot be deleted.')); 00395 $this->_redirect('*/*/editStore', array('store_id' => $model->getId())); 00396 return ; 00397 } 00398 00399 $this->_backupDatabase('*/*/editStore', array('store_id' => $itemId)); 00400 00401 try { 00402 $model->delete(); 00403 00404 Mage::dispatchEvent('store_delete', array('store' => $model)); 00405 00406 $this->_getSession()->addSuccess(Mage::helper('core')->__('Store view was successfully deleted.')); 00407 $this->_redirect('*/*/'); 00408 return ; 00409 } 00410 catch (Mage_Core_Exception $e) { 00411 $this->_getSession()->addError($e->getMessage()); 00412 } 00413 catch (Exception $e) { 00414 $this->_getSession()->addException($e, Mage::helper('core')->__('Unable to delete store view. Please, try again later.')); 00415 } 00416 $this->_redirect('*/*/editStore', array('store_id' => $itemId)); 00417 }
deleteWebsiteAction | ( | ) |
Definition at line 231 of file StoreController.php.
00232 { 00233 $session = $this->_getSession(); 00234 $itemId = $this->getRequest()->getParam('item_id', null); 00235 if (!$model = Mage::getModel('core/website')->load($itemId)) { 00236 $session->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00237 $this->_redirect('*/*/'); 00238 return ; 00239 } 00240 if (!$model->isCanDelete()) { 00241 $session->addError(Mage::helper('core')->__('This website cannot be deleted')); 00242 $this->_redirect('*/*/editWebsite', array('website_id' => $itemId)); 00243 return ; 00244 } 00245 00246 $this->_addDeletionNotice('website'); 00247 00248 $this->_initAction() 00249 ->_addBreadcrumb(Mage::helper('core')->__('Delete Website'), Mage::helper('core')->__('Delete Website')) 00250 ->_addContent($this->getLayout()->createBlock('adminhtml/system_store_delete') 00251 ->setFormActionUrl($this->getUrl('*/*/deleteWebsitePost')) 00252 ->setBackUrl($this->getUrl('*/*/editWebsite', array('website_id' => $itemId))) 00253 ->setStoreTypeTitle(Mage::helper('core')->__('Website')) 00254 ->setDataObject($model) 00255 ) 00256 ->renderLayout(); 00257 }
deleteWebsitePostAction | ( | ) |
Definition at line 316 of file StoreController.php.
00317 { 00318 $itemId = $this->getRequest()->getParam('item_id'); 00319 00320 if (!$model = Mage::getModel('core/website')->load($itemId)) { 00321 $this->_getSession()->addError(Mage::helper('core')->__('Unable to proceed. Please, try again')); 00322 $this->_redirect('*/*/'); 00323 return ; 00324 } 00325 if (!$model->isCanDelete()) { 00326 $this->_getSession()->addError(Mage::helper('core')->__('This website cannot be deleted.')); 00327 $this->_redirect('*/*/editWebsite', array('website_id' => $model->getId())); 00328 return ; 00329 } 00330 00331 $this->_backupDatabase('*/*/editWebsite', array('website_id' => $itemId)); 00332 00333 try { 00334 $model->delete(); 00335 $this->_getSession()->addSuccess(Mage::helper('core')->__('Website was successfully deleted.')); 00336 $this->_redirect('*/*/'); 00337 return ; 00338 } 00339 catch (Mage_Core_Exception $e) { 00340 $this->_getSession()->addError($e->getMessage()); 00341 } 00342 catch (Exception $e) { 00343 $this->_getSession()->addException($e, Mage::helper('core')->__('Unable to delete website. Please, try again later.')); 00344 } 00345 $this->_redirect('*/*/editWebsite', array('website_id' => $itemId)); 00346 }
editGroupAction | ( | ) |
Definition at line 87 of file StoreController.php.
00088 { 00089 Mage::register('store_type', 'group'); 00090 $this->_forward('editStore'); 00091 }
editStoreAction | ( | ) |
Definition at line 93 of file StoreController.php.
00094 { 00095 $session = $this->_getSession(); 00096 if ($session->getPostData()) { 00097 Mage::register('store_post_data', $session->getPostData()); 00098 $session->unsPostData(); 00099 } 00100 if (!Mage::registry('store_type')) { 00101 Mage::register('store_type', 'store'); 00102 } 00103 if (!Mage::registry('store_action')) { 00104 Mage::register('store_action', 'edit'); 00105 } 00106 switch (Mage::registry('store_type')) { 00107 case 'website': 00108 $itemId = $this->getRequest()->getParam('website_id', null); 00109 $model = Mage::getModel('core/website'); 00110 $notExists = Mage::helper('core')->__("Website doesn't exist"); 00111 $codeBase = Mage::helper('core')->__('Before modifying the website code please make sure that it is not used in index.php'); 00112 break; 00113 case 'group': 00114 $itemId = $this->getRequest()->getParam('group_id', null); 00115 $model = Mage::getModel('core/store_group'); 00116 $notExists = Mage::helper('core')->__("Store doesn't exist"); 00117 $codeBase = false; 00118 break; 00119 case 'store': 00120 $itemId = $this->getRequest()->getParam('store_id', null); 00121 $model = Mage::getModel('core/store'); 00122 $notExists = Mage::helper('core')->__("Store view doesn't exist"); 00123 $codeBase = Mage::helper('core')->__('Before modifying the store view code please make sure that it is not used in index.php'); 00124 break; 00125 } 00126 if (null !== $itemId) { 00127 $model->load($itemId); 00128 } 00129 00130 if ($model->getId() || Mage::registry('store_action') == 'add') { 00131 Mage::register('store_data', $model); 00132 00133 if (Mage::registry('store_action') == 'edit' && $codeBase && !$model->isReadOnly()) { 00134 $this->_getSession()->addNotice($codeBase); 00135 } 00136 00137 $this->_initAction() 00138 ->_addContent($this->getLayout()->createBlock('adminhtml/system_store_edit')) 00139 ->renderLayout(); 00140 } 00141 else { 00142 $session->addError($notExists); 00143 $this->_redirect('*/*/'); 00144 } 00145 }
editWebsiteAction | ( | ) |
Definition at line 81 of file StoreController.php.
00082 { 00083 Mage::register('store_type', 'website'); 00084 $this->_forward('editStore'); 00085 }
indexAction | ( | ) |
Definition at line 53 of file StoreController.php.
00054 { 00055 $this->_initAction() 00056 ->_addContent($this->getLayout()->createBlock('adminhtml/system_store_store')) 00057 ->renderLayout(); 00058 }
newGroupAction | ( | ) |
Definition at line 66 of file StoreController.php.
00067 { 00068 Mage::register('store_type', 'group'); 00069 $this->_forward('newStore'); 00070 }
newStoreAction | ( | ) |
Definition at line 72 of file StoreController.php.
00073 { 00074 if (!Mage::registry('store_type')) { 00075 Mage::register('store_type', 'store'); 00076 } 00077 Mage::register('store_action', 'add'); 00078 $this->_forward('editStore'); 00079 }
newWebsiteAction | ( | ) |
Definition at line 60 of file StoreController.php.
00061 { 00062 Mage::register('store_type', 'website'); 00063 $this->_forward('newStore'); 00064 }
saveAction | ( | ) |
Definition at line 147 of file StoreController.php.
00148 { 00149 if ($this->getRequest()->isPost() && $postData = $this->getRequest()->getPost()) { 00150 if (empty($postData['store_type']) || empty($postData['store_action'])) { 00151 $this->_redirect('*/*/'); 00152 return; 00153 } 00154 $session = $this->_getSession(); 00155 00156 try { 00157 switch ($postData['store_type']) { 00158 case 'website': 00159 $websiteModel = Mage::getModel('core/website'); 00160 if ($postData['website']['website_id']) { 00161 $websiteModel->load($postData['website']['website_id']); 00162 } 00163 $websiteModel->setData($postData['website']); 00164 if ($postData['website']['website_id'] == '') { 00165 $websiteModel->setId(null); 00166 } 00167 00168 $websiteModel->save(); 00169 $session->addSuccess(Mage::helper('core')->__('Website was successfully saved')); 00170 break; 00171 00172 case 'group': 00173 $groupModel = Mage::getModel('core/store_group'); 00174 if ($postData['group']['group_id']) { 00175 $groupModel->load($postData['group']['group_id']); 00176 } 00177 $groupModel->setData($postData['group']); 00178 if ($postData['group']['group_id'] == '') { 00179 $groupModel->setId(null); 00180 } 00181 00182 $groupModel->save(); 00183 00184 Mage::dispatchEvent('store_group_save', array('group' => $groupModel)); 00185 00186 $session->addSuccess(Mage::helper('core')->__('Store was successfully saved')); 00187 break; 00188 00189 case 'store': 00190 $eventName = 'store_edit'; 00191 $storeModel = Mage::getModel('core/store'); 00192 if ($postData['store']['store_id']) { 00193 $storeModel->load($postData['store']['store_id']); 00194 } 00195 $storeModel->setData($postData['store']); 00196 if ($postData['store']['store_id'] == '') { 00197 $storeModel->setId(null); 00198 $eventName = 'store_add'; 00199 } 00200 $groupModel = Mage::getModel('core/store_group')->load($storeModel->getGroupId()); 00201 $storeModel->setWebsiteId($groupModel->getWebsiteId()); 00202 $storeModel->save(); 00203 00204 Mage::app()->reinitStores(); 00205 00206 Mage::dispatchEvent($eventName, array('store'=>$storeModel)); 00207 00208 $session->addSuccess(Mage::helper('core')->__('Store View was successfully saved')); 00209 break; 00210 default: 00211 $this->_redirect('*/*/'); 00212 return; 00213 } 00214 $this->_redirect('*/*/'); 00215 return; 00216 } 00217 catch (Mage_Core_Exception $e) { 00218 $session->addError($e->getMessage()); 00219 $session->setPostData($postData); 00220 } 00221 catch (Exception $e) { 00222 $session->addException($e, Mage::helper('core')->__('Error while saving. Please try again later.')); 00223 $session->setPostData($postData); 00224 } 00225 $this->_redirectReferer(); 00226 return; 00227 } 00228 $this->_redirect('*/*/'); 00229 }