/** * save rewrites action * @access public */ public function saveAction() { $rewrites = $this->getRequest()->getPost('rewrite'); if (!$rewrites) { $this->_getSession()->addError(Mage::helper('easylife_cmsrewrites')->__('Add at least one rewrite')); $this->_redirect('*/*/'); return; } $stores = $this->getStores(); $toInsert = array(); foreach ($rewrites as $rewrite) { $rewriteObj = new Varien_Object($rewrite); $redirect = $rewriteObj->getRedirect(); foreach ($stores as $storeFrom) { foreach ($stores as $storeTo) { if ($storeFrom->getId() == $storeTo->getId() || $rewriteObj->getData('store_' . $storeFrom->getId()) == $rewriteObj->getData('store_' . $storeTo->getId()) || !$rewriteObj->getData('store_' . $storeFrom->getId()) || !$rewriteObj->getData('store_' . $storeTo->getId())) { continue; } $item = array(); $item['store_id'] = $storeTo->getId(); $item['category_id'] = null; $item['product_id'] = null; $item['is_system'] = 0; $item['request_path'] = $rewriteObj->getData('store_' . $storeFrom->getId()); $item['target_path'] = $rewriteObj->getData('store_' . $storeTo->getId()); $item['options'] = $redirect; $item['id_path'] = uniqid('cmsrewrite_'); $toInsert[$item['request_path'] . '_' . $item['store_id']] = $item; } } } if (count($toInsert)) { /** @var Mage_Core_Model_Resource $resource */ $resource = Mage::getSingleton('core/resource'); /** @var Varien_Db_Adapter_Interface $adapter */ $adapter = $resource->getConnection('core_write'); $table = $resource->getTableName('core/url_rewrite'); $adapter->insertOnDuplicate($table, $toInsert); $this->_getSession()->addSuccess(Mage::helper('easylife_cmsrewrites')->__('%s Url rewrites were created', count($toInsert))); $this->_redirect('*/*/'); return; } $this->_getSession()->addError(Mage::helper('easylife_cmsrewrites')->__('No Url rewrite found')); $this->_redirect('*/*/'); return; }
public function noCookiesAction() { $redirect = new Varien_Object(); Mage::dispatchEvent('controller_action_nocookies', array('action' => $this, 'redirect' => $redirect)); if ($url = $redirect->getRedirectUrl()) { $this->_redirectUrl($url); } elseif ($redirect->getRedirect()) { $this->_redirect($redirect->getPath(), $redirect->getArguments()); } else { $this->loadLayout(array('default', 'noCookie')); $this->renderLayout(); } $this->getRequest()->setDispatched(true); }