Public Member Functions | |
indexAction () | |
saveAction () | |
refreshCatalogRewritesAction () | |
clearImagesCacheAction () | |
refreshLayeredNavigationAction () | |
Protected Member Functions | |
_getSession () | |
_isAllowed () |
Definition at line 34 of file CacheController.php.
_getSession | ( | ) | [protected] |
Retrieve session model
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 41 of file CacheController.php.
00042 { 00043 return Mage::getSingleton('adminhtml/session'); 00044 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 324 of file CacheController.php.
00325 { 00326 return Mage::getSingleton('admin/session')->isAllowed('system/cache'); 00327 }
clearImagesCacheAction | ( | ) |
Definition at line 288 of file CacheController.php.
00289 { 00290 try { 00291 Mage::getModel('catalog/product_image')->clearCache(); 00292 $this->_getSession()->addSuccess( 00293 Mage::helper('adminhtml')->__('Image cache was cleared successfully') 00294 ); 00295 } 00296 catch (Mage_Core_Exception $e) { 00297 $this->_getSession()->addError($e->getMessage()); 00298 } 00299 catch (Exception $e) { 00300 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while cleared Image cache. Please try again later')); 00301 } 00302 00303 $this->_redirect('*/*'); 00304 }
indexAction | ( | ) |
Display cache management form
Definition at line 49 of file CacheController.php.
00050 { 00051 $this->loadLayout() 00052 ->_setActiveMenu('system/cache') 00053 ->_addContent($this->getLayout()->createBlock('adminhtml/system_cache_edit')->initForm()) 00054 ->renderLayout(); 00055 }
refreshCatalogRewritesAction | ( | ) |
Definition at line 270 of file CacheController.php.
00271 { 00272 try { 00273 Mage::getSingleton('catalog/url')->refreshRewrites(); 00274 $this->_getSession()->addSuccess( 00275 Mage::helper('adminhtml')->__('Catalog Rewrites was refreshed successfully') 00276 ); 00277 } 00278 catch (Mage_Core_Exception $e) { 00279 $this->_getSession()->addError($e->getMessage()); 00280 } 00281 catch (Exception $e) { 00282 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while refreshed Catalog Rewrites. Please try again later')); 00283 } 00284 00285 $this->_redirect('*/*'); 00286 }
refreshLayeredNavigationAction | ( | ) |
Definition at line 306 of file CacheController.php.
00307 { 00308 try { 00309 Mage::getSingleton('catalogindex/indexer')->plainReindex(); 00310 $this->_getSession()->addSuccess( 00311 Mage::helper('adminhtml')->__('Layered Navigation Indices was refreshed successfully') 00312 ); 00313 } 00314 catch (Mage_Core_Exception $e) { 00315 $this->_getSession()->addError($e->getMessage()); 00316 } 00317 catch (Exception $e) { 00318 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while refreshed Layered Navigation Indices. Please try again later')); 00319 } 00320 00321 $this->_redirect('*/*'); 00322 }
saveAction | ( | ) |
Seva cache settings
Protect empty post data
Process cache settings
Run catalog actions
Definition at line 60 of file CacheController.php.
00061 { 00062 /** 00063 * Protect empty post data 00064 */ 00065 $postData = $this->getRequest()->getPost(); 00066 if (empty($postData)) { 00067 $this->_redirect('*/*'); 00068 return; 00069 } 00070 00071 /** 00072 * Process cache settings 00073 */ 00074 $allCache = $this->getRequest()->getPost('all_cache'); 00075 if ($allCache=='disable' || $allCache=='refresh') { 00076 Mage::app()->cleanCache(); 00077 } 00078 00079 $e = $this->getRequest()->getPost('enable'); 00080 $enable = array(); 00081 $clean = array(); 00082 $cacheTypes = array_keys(Mage::helper('core')->getCacheTypes()); 00083 foreach ($cacheTypes as $type) { 00084 $flag = $allCache!='disable' && (!empty($e[$type]) || $allCache=='enable'); 00085 $enable[$type] = $flag ? 1 : 0; 00086 if ($allCache=='' && !$flag) { 00087 $clean[] = $type; 00088 } 00089 } 00090 00091 $beta = $this->getRequest()->getPost('beta'); 00092 $betaCache = array_keys(Mage::helper('core')->getCacheBetaTypes()); 00093 00094 foreach ($betaCache as $type) { 00095 if (empty($beta[$type])) { 00096 $clean[] = $type; 00097 } else { 00098 $enable[$type] = 1; 00099 } 00100 } 00101 00102 if (!empty($clean)) { 00103 Mage::app()->cleanCache($clean); 00104 } 00105 Mage::app()->saveUseCache($enable); 00106 00107 /** 00108 * Run catalog actions 00109 */ 00110 if ($catalogAction = $this->getRequest()->getPost('catalog_action')) { 00111 switch ($catalogAction) { 00112 case 'refresh_catalog_rewrites': 00113 try { 00114 Mage::getSingleton('catalog/url')->refreshRewrites(); 00115 $this->_getSession()->addSuccess( 00116 Mage::helper('adminhtml')->__('Catalog Rewrites were refreshed successfully') 00117 ); 00118 } 00119 catch (Mage_Core_Exception $e) { 00120 $this->_getSession()->addError($e->getMessage()); 00121 } 00122 catch (Exception $e) { 00123 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while refreshed Catalog Rewrites. Please try again later')); 00124 } 00125 break; 00126 00127 case 'clear_images_cache': 00128 try { 00129 Mage::getModel('catalog/product_image')->clearCache(); 00130 $this->_getSession()->addSuccess( 00131 Mage::helper('adminhtml')->__('Image cache was cleared successfully') 00132 ); 00133 } 00134 catch (Mage_Core_Exception $e) { 00135 $this->_getSession()->addError($e->getMessage()); 00136 } 00137 catch (Exception $e) { 00138 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while cleared Image cache. Please try again later')); 00139 } 00140 break; 00141 00142 case 'refresh_layered_navigation_now': 00143 try { 00144 $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf(); 00145 if ($flag->getState() == Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING) { 00146 $kill = Mage::getModel('catalogindex/catalog_index_kill_flag')->loadSelf(); 00147 $kill->setFlagData($flag->getFlagData())->save(); 00148 } 00149 00150 $flag->setState(Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED)->save(); 00151 Mage::getSingleton('catalogindex/indexer')->plainReindex(); 00152 $this->_getSession()->addSuccess( 00153 Mage::helper('adminhtml')->__('Layered Navigation Indices were refreshed successfully') 00154 ); 00155 } 00156 catch (Mage_Core_Exception $e) { 00157 $this->_getSession()->addError($e->getMessage()); 00158 } 00159 catch (Exception $e) { 00160 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while refreshed Layered Navigation Indices. Please try again later')); 00161 } 00162 break; 00163 00164 case 'refresh_layered_navigation': 00165 try { 00166 $flag = Mage::getModel('catalogindex/catalog_index_flag')->loadSelf(); 00167 switch ($flag->getState()) { 00168 case Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED: 00169 $flag->delete(); 00170 $this->_getSession()->addSuccess( 00171 Mage::helper('adminhtml')->__('Layered Navigation indexing queue cancelled') 00172 ); 00173 break; 00174 case Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_RUNNING: 00175 $kill = Mage::getModel('catalogindex/catalog_index_kill_flag')->loadSelf(); 00176 $kill->setFlagData($flag->getFlagData())->save(); 00177 $this->_getSession()->addSuccess( 00178 Mage::helper('adminhtml')->__('Layered Navigation process queued to be killed') 00179 ); 00180 break; 00181 default: 00182 $flag->setState(Mage_CatalogIndex_Model_Catalog_Index_Flag::STATE_QUEUED)->save(); 00183 $this->_getSession()->addSuccess( 00184 Mage::helper('adminhtml')->__('Layered Navigation indexing queued') 00185 ); 00186 break; 00187 } 00188 } 00189 catch (Mage_Core_Exception $e) { 00190 $this->_getSession()->addError($e->getMessage()); 00191 } 00192 catch (Exception $e) { 00193 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Error while refreshed Layered Navigation Indices. Please try again later')); 00194 } 00195 break; 00196 00197 case 'rebuild_search_index': 00198 try { 00199 Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(); 00200 $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('Search Index was rebuilt successfully')); 00201 } 00202 catch (Mage_Core_Exception $e) { 00203 $this->_getSession()->addError($e->getMessage()); 00204 } 00205 catch (Exception $e) { 00206 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Search Index rebuild error. Please try again later')); 00207 } 00208 break; 00209 00210 case 'rebuild_inventory_stock_status': 00211 try { 00212 Mage::getSingleton('cataloginventory/stock_status')->rebuild(); 00213 $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('CatalogInventory Stock Status was rebuilt successfully')); 00214 } 00215 catch (Mage_Core_Exception $e) { 00216 $this->_getSession()->addError($e->getMessage()); 00217 } 00218 catch (Exception $e) { 00219 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('CatalogInventory Stock Status rebuild error. Please try again later')); 00220 } 00221 break; 00222 00223 case 'rebuild_catalog_index': 00224 try { 00225 Mage::getSingleton('catalog/index')->rebuild(); 00226 $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('Catalog Index was rebuilt successfully')); 00227 } 00228 catch (Mage_Core_Exception $e) { 00229 $this->_getSession()->addError($e->getMessage()); 00230 } 00231 catch (Exception $e) { 00232 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Catalog Index rebuild error. Please try again later')); 00233 } 00234 break; 00235 00236 case 'rebuild_flat_catalog_category': 00237 try { 00238 Mage::getResourceModel('catalog/category_flat')->rebuild(); 00239 $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('Flat Catalog Category was rebuilt successfully')); 00240 } 00241 catch (Mage_Core_Exception $e) { 00242 $this->_getSession()->addError($e->getMessage()); 00243 } 00244 catch (Exception $e) { 00245 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Flat Catalog Category rebuild error')); 00246 } 00247 break; 00248 00249 case 'rebuild_flat_catalog_product': 00250 try { 00251 Mage::getResourceModel('catalog/product_flat_indexer')->rebuild(); 00252 $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__('Flat Catalog Product was rebuilt successfully')); 00253 } 00254 catch (Mage_Core_Exception $e) { 00255 $this->_getSession()->addError($e->getMessage()); 00256 } 00257 catch (Exception $e) { 00258 $this->_getSession()->addException($e, Mage::helper('adminhtml')->__('Flat Catalog Product rebuild error. Please try again later')); 00259 } 00260 break; 00261 00262 default: 00263 break; 00264 } 00265 } 00266 00267 $this->_redirect('*/*'); 00268 }