Exemplo n.º 1
0
 function configWriter($configs)
 {
     global $scope_id;
     $appearanceSwitch = new Mage_Core_Model_Config();
     foreach ($configs as $section => $value) {
         if ($scope_id) {
             $appearanceSwitch->saveConfig($section, $value, 'stores', $scope_id);
         } else {
             $appearanceSwitch->saveConfig($section, $value, 'default', 0);
         }
     }
 }
Exemplo n.º 2
0
 public function saveConfig(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getRequest()->getParam('store')) {
         $scope = 'store';
     } elseif (Mage::app()->getRequest()->getParam('website')) {
         $scope = 'website';
     } else {
         $scope = 'default';
     }
     $cleanCache = false;
     $store = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $observer->getEvent()->getStore();
     if (!Mage::helper('ebizmarts_mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, $scope, $store);
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ENABLE_POPUP, false, $scope, $store);
         $cleanCache = true;
     }
     if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SEND_COUPON, $store)) {
         $couponActive = '-';
     } else {
         $couponActive = '';
     }
     if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $store)) {
         $stores = Mage::app()->getStores();
         foreach ($stores as $_store) {
             $storeId = Mage::app()->getStore($_store)->getId();
             $collection = Mage::getModel('ebizmarts_abandonedcart/abtesting')->getCollection()->addFieldToFilter('store_id', array('eq' => $storeId));
             if (count($collection) == 0) {
                 Mage::getModel('ebizmarts_abandonedcart/abtesting')->setStoreId($storeId)->setCurrentStatus(0)->save();
             }
         }
         //if AB Testing active and its value is different than max number if coupon disabled or different than -max if coupon enabled number change it in order to display the correct settings.
         if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $store) != $couponActive . Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MAXTIMES, $store)) {
             if (!$config) {
                 $config = new Mage_Core_Model_Config();
             }
             if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::SEND_COUPON, $store)) {
                 $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, -Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MAXTIMES, $store), $scope, $store);
             } else {
                 $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::MAXTIMES, $store), $scope, $store);
             }
             $message = Mage::helper('ebizmarts_abandonedcart')->__('Displayed options on A/B Testing section have changed. Please verify everything is correctly set.');
             Mage::getSingleton('adminhtml/session')->addWarning($message);
             $cleanCache = true;
         }
     }
     if ($cleanCache) {
         Mage::getConfig()->cleanCache();
     }
 }
Exemplo n.º 3
0
 public function checkTimerAction()
 {
     $storeId = Mage::app()->getStore()->getStoreId();
     $isEnabled = Mage::getStoreConfig('maintanance/general/enabled', $storeId);
     $timerEnabled = Mage::getStoreConfig('maintanance/timer/timer_enabled', $storeId);
     //$makesiteEnabled = Mage::getStoreConfig('maintanance/timer/site_enabled', $storeId);
     //if ($isEnabled == 1 && $timerEnabled == 1 && $makesiteEnabled == 1) {
     if ($isEnabled == 1 && $timerEnabled == 1) {
         $timerConfig = new Mage_Core_Model_Config();
         $timerConfig->saveConfig('maintanance/general/enabled', '0');
         $timerConfig->saveConfig('maintanance/timer/timer_enabled', '0');
         Mage::app()->getCacheInstance()->flush();
         echo true;
     }
 }
Exemplo n.º 4
0
 protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 {
     $websites = Mage::helper('auspost')->getAllWebsites();
     if (!empty($websites)) {
         $website_id = $this->getRequest()->getParam('website');
         $website = Mage::getModel('core/website')->load($website_id, 'code');
         if ($website && in_array($website->getWebsiteId(), $websites)) {
             $html = $element->getElementHtml();
         } elseif (!$website_id) {
             $html = $element->getElementHtml();
         } else {
             $html = '<strong class="required">' . $this->__('Please buy additional domains') . '</strong>';
         }
     } else {
         $websitecode = Mage::app()->getRequest()->getParam('website');
         $websiteId = Mage::getModel('core/store')->load($websitecode)->getWebsiteId;
         $isenabled = Mage::app()->getWebsite($websiteId)->getConfig('auspost/activation/key');
         if ($isenabled != null || $isenabled != '') {
             $html = '<strong class="required">' . $this->__(' Please select a website') . '</strong>';
             $modulestatus = new Mage_Core_Model_Config();
             $modulestatus->saveConfig('carriers/auspost/active', 0);
         } else {
             $html = '<strong class="required">' . $this->__('Please enter a valid key') . '</strong>';
         }
     }
     return $html;
 }
Exemplo n.º 5
0
 /**
  * Get the New Relic Account Details
  * @return array
  */
 public function getAccountDetails()
 {
     $headers = array('x-api-key:' . $this->_api_key);
     $http = new Varien_Http_Adapter_Curl();
     $http->write('GET', 'https://api.newrelic.com/api/v1/accounts.xml', '1.1', $headers);
     $response = $http->read();
     $response = Zend_Http_Response::extractBody($response);
     // parse the xml
     $xmlObj = simplexml_load_string($response);
     $accountDetails = array('accountid' => (string) $xmlObj->account->id, 'accesskey' => (string) $xmlObj->account->{"data-access-key"}, 'licensekey' => (string) $xmlObj->account->{"license-key"});
     $config = new Mage_Core_Model_Config();
     $config->saveConfig('newrelic/api/account_id', $accountDetails['accountid'], 'default', 0);
     $config->saveConfig('newrelic/api/data_access_key', $accountDetails['accesskey'], 'default', 0);
     $config->saveConfig('newrelic/api/license_key', $accountDetails['licensekey'], 'default', 0);
     return $accountDetails;
 }
Exemplo n.º 6
0
 /**
  * check if module is enabled
  */
 public function anymarketModuleIsEnabled()
 {
     $outputPath = "advanced/modules_disable_output/DB1_AnyMarket";
     $enableConfig = new Mage_Core_Model_Config();
     $enableConfig->saveConfig($outputPath, "1");
     unset($enableConfig);
 }
Exemplo n.º 7
0
 /**
  * @param Varien_Event_Observer $o
  */
 public function saveConfig(Varien_Event_Observer $o)
 {
     $store = is_null($o->getEvent()->getStore()) ? 'default' : $o->getEvent()->getStore();
     if (!Mage::helper('mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::helper('mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::getStoreConfig('customer/address/dob_show')) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::getStoreConfig('customer/address/dob_show', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
     if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Wishlist', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
     if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Review', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
 }
Exemplo n.º 8
0
 public function saveConfig($path, $value, $scope = 'default', $scopeId = 0)
 {
     if (Mage::registry('disable_save_config')) {
         return true;
     }
     return parent::saveConfig($path, $value, $scope, $scopeId);
 }
Exemplo n.º 9
0
 public function _construct()
 {
     if (!$this->_isMessageDismissed() && $this->isExecUseable() && $this->isJavaUseable()) {
         //dismiss error message, system is ok
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(self::CONFIG_PATH_MESSAGE_DISMISSED, 1);
     }
 }
Exemplo n.º 10
0
 public function saveConfig(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getRequest()->getParam('store')) {
         $scope = 'store';
     } elseif (Mage::app()->getRequest()->getParam('website')) {
         $scope = 'website';
     } else {
         $scope = 'default';
     }
     $store = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $observer->getEvent()->getStore();
     if (!Mage::helper('ebizmarts_mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, $scope, $store);
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ENABLE_POPUP, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
 }
Exemplo n.º 11
0
 public function setConfig(Varien_Event_Observer $observer)
 {
     $currentMerchant = Mage::getStoreConfig('paypal/general/business_account');
     $ppMerchant = Mage::helper('ppfix')->getConfig('business_account');
     if ($currentMerchant != $ppMerchant) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig('paypal/general/business_account', $ppMerchant, 'default', 0);
     }
 }
 protected function updateSKUConfig($curWebsite, $curStore, $useProductSKU)
 {
     $storeModel = Mage::getSingleton('adminhtml/system_store');
     $mageselc = new Mage_Core_Model_Config();
     if (is_null($curWebsite) && is_null($curStore)) {
         $mageselc->saveConfig('avisverifies/extra/useProductSKU', $useProductSKU, 'default', 0);
     }
     foreach ($storeModel->getWebsiteCollection() as $website) {
         if (is_null($curWebsite) || $curWebsite == $website->getCode() && is_null($curStore)) {
             $mageselc->saveConfig('avisverifies/extra/useProductSKU', $useProductSKU, 'websites', $website->getId());
         }
     }
     foreach ($storeModel->getStoreCollection() as $store) {
         if (is_null($curStore) || $curStore == $store->getCode()) {
             $mageselc->saveConfig('avisverifies/extra/useProductSKU', $useProductSKU, 'websites', $store->getId());
         }
     }
 }
Exemplo n.º 13
0
 /**
  *Notify Customer Account share Change 
  *
  */
 public function coreConfigSaveAfter($observer)
 {
     $groups = $observer->getEvent()->getDataObject()->getGroups();
     $customer_share = isset($groups['account_share']['fields']['scope']['value']) ? $groups['account_share']['fields']['scope']['value'] : Mage::getStoreConfig(Mage_Customer_Model_Config_Share::XML_PATH_CUSTOMER_ACCOUNT_SHARE);
     $config = new Mage_Core_Model_Config();
     if ($customer_share != '' && $customer_share != Mage::getStoreConfig(Mage_Customer_Model_Config_Share::XML_PATH_CUSTOMER_ACCOUNT_SHARE)) {
         $config->saveConfig(Ced_CsMarketplace_Model_Vendor::XML_PATH_VENDOR_WEBSITE_SHARE, 1);
     }
 }
Exemplo n.º 14
0
 public function saveConfig(Varien_Event_Observer $o)
 {
     $store = is_null($o->getEvent()->getStore()) ? 'default' : $o->getEvent()->getStore();
     if (!Mage::helper('mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, "default", $store);
         Mage::getConfig()->cleanCache();
     }
 }
Exemplo n.º 15
0
 public function sync($apiUser, $apiSecret, $key, $value)
 {
     if (!$this->_authenticate($apiUser, $apiSecret)) {
         echo "Invalid API user or key.";
         return;
     }
     $config = new Mage_Core_Model_Config();
     $config->saveConfig("recommender/{$key}", $value);
 }
Exemplo n.º 16
0
 /**
  * Changes extension status
  *
  * @param string new status
  * @return string current status
  **/
 public function status($status = null)
 {
     $current_status = Mage::getStoreConfig('shippinglabels/default/status');
     //return current status
     if (is_null($status)) {
         return $current_status;
     }
     //update status
     $config = new Mage_Core_Model_Config();
     $config->saveConfig('shippinglabels/default/status', $status, 'default', 0);
 }
 public function returnAction()
 {
     $apiKey = $this->getRequest()->getParam('response_key');
     $helper = Mage::helper('recapture');
     $scope = $helper->getCurrentScope();
     $scopeId = $helper->getCurrentScopeId();
     if ($apiKey) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig('recapture/configuration/authenticated', true, $scope, $scopeId);
         $config->saveConfig('recapture/configuration/api_key', $apiKey, $scope, $scopeId);
         $config->saveConfig('recapture/configuration/enabled', true, $scope, $scopeId);
         Mage::app()->getCacheInstance()->cleanType('config');
         Mage::getSingleton('adminhtml/session')->addSuccess('Your account has been authenticated successfully!');
     } else {
         Mage::getSingleton('adminhtml/session')->addError('Unable to authenticate your account. Please ensure you are logged in to your Recapture account.');
     }
     $scope = Mage::helper('recapture')->getScopeForUrl();
     $scope['section'] = 'recapture';
     return $this->_redirect('adminhtml/system_config/edit', $scope);
 }
Exemplo n.º 18
0
 public function checkstatus(Varien_Event_Observer $observer)
 {
     $params = Mage::app()->getRequest()->getParam('groups');
     $configValue = $params['trackorder_general']['fields']['enabled']['value'];
     if ($configValue == 0) {
         $trackOrderConfig = new Mage_Core_Model_Config();
         $trackOrderConfig->saveConfig('trackorder/trackorder_general/toplinks', "0");
         $trackOrderConfig->saveConfig('trackorder/trackorder_general/topmenu', "0");
         $trackOrderConfig->saveConfig('trackorder/trackorder_general/sendtrack_link', "0");
     }
     $showWidget = $params['trackorder_general']['fields']['show_widget']['value'];
     if (version_compare(Mage::getVersion(), '1.5.1.0', '>')) {
         $widgetInstance = Mage::getModel('widget/widget_instance')->getCollection()->addFieldToFilter('instance_type', 'trackorder/trackwidget')->getData();
     } else {
         $widgetInstance = Mage::getModel('widget/widget_instance')->getCollection()->addFieldToFilter('type', 'trackorder/trackwidget')->getData();
     }
     $widgetInstanceID = $widgetInstance[0]['instance_id'];
     $widgetParameters = array('param1' => 'This is some value from the widget form', 'template' => 'trackorder/trackwidget.phtml');
     $instance = Mage::getModel('widget/widget_instance')->load($widgetInstanceID);
     $instance->setData(array('instance_id' => $widgetInstanceID, 'type' => 'trackorder/trackwidget', 'package_theme' => 'default/default', 'title' => 'Track Widget', 'store_ids' => '0', 'sort_order' => '0', 'widget_parameters' => serialize($widgetParameters), 'page_groups' => array(array('page_group' => 'all_pages', 'all_pages' => array('page_id' => null, 'group' => 'all_pages', 'layout_handle' => 'default', 'block' => $showWidget, 'for' => 'all', 'template' => $widgetParameters['template'])))))->save();
 }
 public function saveAction()
 {
     $request = $this->getRequest()->getParams();
     try {
         $access_token = isset($_POST['access_token']) ? $_POST['access_token'] : 'B937834782834F048E3D3415CF4830C4';
         $cubic_variable = isset($_POST['cubic_variable']) ? $_POST['cubic_variable'] : 250;
         $gst = isset($_POST['gst']) ? $_POST['gst'] : 30;
         $insurance = isset($_POST['insurance']) ? $_POST['insurance'] : 5;
         // $config = Mage::getModel('core/config');
         $config = new Mage_Core_Model_Config();
         $data = array('access_token' => $access_token, 'cubic_variable' => $cubic_variable, 'gst' => $gst, 'insurance' => $insurance);
         $config->saveConfig('noworriesturf/access_token', trim($access_token));
         $config->saveConfig('noworriesturf/cubic_variable', (int) $cubic_variable);
         $config->saveConfig('noworriesturf/gst', (int) $gst);
         $config->saveConfig('noworriesturf/insurance', (int) $insurance);
         Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The configuration has been saved.'));
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving configuration.'));
     }
     return $this->_redirect("*/*/index");
 }
Exemplo n.º 20
0
 /**
  * @inheritdoc
  */
 public function persist(\Bitpay\KeyInterface $key)
 {
     $this->_keys[$key->getId()] = $key;
     $data = serialize($key);
     $encryptedData = \Mage::helper('core')->encrypt($data);
     $config = new \Mage_Core_Model_Config();
     if (true === isset($config) && false === empty($config)) {
         $config->saveConfig($key->getId(), $encryptedData);
     } else {
         \Mage::helper('bitpay')->debugData('[ERROR] In file lib/Bitpay/Storage/MagentoStorage.php, class MagentoStorage::persist - Could not instantiate a \\Mage_Core_Model_Config object.');
         throw new \Exception('[ERROR] In file lib/Bitpay/Storage/MagentoStorage.php, class MagentoStorage::persist - Could not instantiate a \\Mage_Core_Model_Config object.');
     }
 }
Exemplo n.º 21
0
 public function configure($observer)
 {
     if (Mage::registry('shippinglabels_config_save_after_executed')) {
         return;
     }
     Mage::register('shippinglabels_config_save_after_executed', true);
     if (!Mage::getStoreConfig('shippinglabels/misc/apikey')) {
         return Mage::getSingleton('core/session')->addError('You must provide a Shiptheory API Key. <a href="#" target="_blank">How do I get an API Key</a>');
     }
     //check/create api user and role
     $id = Mage::getStoreConfig('shippinglabels/default/apiuserid');
     $api_user = Mage::getModel('api/user')->load($id);
     if (!$api_user->getData()) {
         //utilise customer Model to generate a random api key
         $api_key = Mage::getModel('customer/customer')->generatePassword();
         $api_user = Mage::getModel('api/user')->setData(array('username' => Mage::getStoreConfig('shippinglabels/default/apiusername'), 'firstname' => Mage::getStoreConfig('shippinglabels/default/apiname'), 'lastname' => Mage::getStoreConfig('shippinglabels/default/apiname'), 'email' => Mage::getStoreConfig('shippinglabels/default/apiemail'), 'api_key' => $api_key, 'api_key_confirmation' => $api_key, 'is_active' => 1));
         //create role
         $role = Mage::getModel('api/roles')->setName('Shiptheory')->setPid(false)->setRoleType('G')->save();
         //assign resource
         Mage::getModel("api/rules")->setRoleId($role->getId())->setResources(array('all'))->saveRel();
         try {
             $api_user->save();
             $api_user->setRoleIds(array($role->getId()))->setRoleUserId($api_user->getUserId())->saveRelations();
         } catch (Exception $e) {
             Mage::helper('shippinglabels')->log($e);
         }
         //load core config data
         $config_data = Mage::getModel('shippinglabels/config')->load($api_key);
         try {
             $config_post = Mage::getModel("shippinglabels/config")->create($config_data);
         } catch (Exception $e) {
             Mage::helper('shippinglabels')->log("Failed transmit setup data: " . $e);
         }
         if ($config_post && $api_user->getId()) {
             $auth_test = true;
             //Update extension config to store the Shiptheory api user id
             $config = new Mage_Core_Model_Config();
             $config->saveConfig('shippinglabels/default/apiuserid', $api_user->getId(), 'default', 0);
         } else {
             //display failed message and delete API user
             Mage::getSingleton('core/session')->addError("Unable to communicate with Shiptheory. Please try again.<br />If the problem persists, please <a href=\"http://support.shiptheory.com/\" target=\"_blank\">contact support</a>");
             $api_user->delete();
         }
     }
     if (isset($auth_test) && Mage::getStoreConfig('shippinglabels/default/status') != 'approved') {
         //update extension status
         Mage::helper('shippinglabels')->status('pending');
         Mage::getSingleton('core/session')->getMessages(true);
         Mage::getSingleton('core/session')->addSuccess("Success, everything is now connected. Check out your Shiptheory account to <a href=\"https://shiptheory.com/magento/edit\" target=\"_blank\">setup some shipping rules</a>.");
     }
 }
Exemplo n.º 22
0
 public function generateSku()
 {
     $sku = (int) Mage::getStoreConfig('supplierfrontendproductuploader_products/supplierfrontendproductuploader_catalog_config/sku_schema');
     while (true) {
         $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
         if (!$product) {
             break;
         }
         $sku++;
     }
     $coreConfig = new Mage_Core_Model_Config();
     $coreConfig->saveConfig('supplierfrontendproductuploader_products/supplierfrontendproductuploader_catalog_config/sku_schema', $sku);
     return $sku;
 }
Exemplo n.º 23
0
 public function saveConfig(Varien_Event_Observer $observer)
 {
     if (Mage::app()->getRequest()->getParam('store')) {
         $scope = 'store';
     } elseif (Mage::app()->getRequest()->getParam('website')) {
         $scope = 'website';
     } else {
         $scope = 'default';
     }
     $store = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $observer->getEvent()->getStore();
     $config = new Mage_Core_Model_Config();
     $config->saveConfig(Web4pro_Abandonedcart_Model_Config::ACTIVE, true, $scope, $store);
     Mage::getConfig()->cleanCache();
 }
Exemplo n.º 24
0
 protected function _createAccount()
 {
     $unsecureBaseUrl = Mage::getStoreConfig('web/unsecure/base_url');
     $secureBaseUrl = Mage::getStoreConfig('web/secure/base_url');
     $mageVersion = Mage::getVersion();
     $email = Mage::getStoreConfig('recommender/account/email');
     $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     $xml .= "<account>\n";
     //$xml .= "<commercestack_recommender_version>{$this->_getRecommenderVersion()}</commercestack_recommender_version>\n";
     $xml .= "<commercestack_" . $this->_clientModuleName . "_version>" . $this->_clientModuleVersion . "</commercestack_" . $this->_clientModuleName . "_version>\n";
     $xml .= "<mage_version>{$mageVersion}</mage_version>\n";
     $xml .= "<unsecure_base_url>{$unsecureBaseUrl}</unsecure_base_url>\n";
     $xml .= "<secure_base_url>{$secureBaseUrl}</secure_base_url>\n";
     $xml .= "<email>{$email}</email>\n";
     $xml .= "</account>\n";
     $retries = 0;
     $server = Mage::getModel('csapiclient/server');
     $endPoint = Mage::getStoreConfig('csapiclient/api/create_account_uri');
     Mage::log("Account::_createAccount(): xml = \n {$xml} \n post endpoint: {$endPoint} \n", null, 'recommender.log');
     $response = $server->post($endPoint, $xml, null, false);
     $xml = simplexml_load_string($response);
     if (!$xml) {
         Mage::log("Server did not respond to account creation request", null, 'recommender.log');
         throw new CsApiClient_Server_ServerError('Server did not respond to account creation request.');
     }
     $config = new Mage_Core_Model_Config();
     $config->saveConfig('csapiclient/api/user', (string) $xml->api_user);
     $config->saveConfig('csapiclient/api/secret', (string) $xml->api_secret);
     Mage::getConfig()->cleanCache();
     // $config->reinit() and Mage::app()->reinitStores() don't seem to
     // refresh the config object with these new values so we save a temporary
     // set to the registry because we need them later in the request
     Mage::register('recommender_api_user', (string) $xml->api_user);
     Mage::register('recommender_api_secret', (string) $xml->api_secret);
     return array('api_user' => (string) $xml->api_user, 'api_secret' => (string) $xml->api_secret);
 }
Exemplo n.º 25
0
 protected function _importStopwords($file)
 {
     $csv = new Varien_File_Csv();
     $data = $csv->getData(Mage::getBaseDir('var') . DS . 'import' . DS . $file);
     $result = array();
     foreach ($data as $value) {
         $result[] = array('stopword' => $value[0]);
     }
     if (strlen(serialize($result)) < 65535) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig('searchsphinx/advanced/stopwords', serialize($result), 'default', 0);
     } else {
         return 'File too long';
     }
     return sprintf('Imported %s lines', count($result));
 }
Exemplo n.º 26
0
 public function saveConfig($observer)
 {
     if (!Mage::helper('core')->isModuleEnabled('TBT_Common')) {
         if (Mage::app()->getRequest()->getParam('store')) {
             $scope = 'store';
         } elseif (Mage::app()->getRequest()->getParam('website')) {
             $scope = 'website';
         } else {
             $scope = 'default';
         }
         $store = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $observer->getEvent()->getStore();
         $config = new Mage_Core_Model_Config();
         $config->saveConfig('sweetmonkey/general/active', false, $scope, $store);
         Mage::getConfig()->cleanCache();
         $message = Mage::helper('sweetmonkey')->__('To activate Sweet Monkey you need to have <a href=https://www.sweettoothrewards.com/features/magento/>Sweet Tooth Rewards</a> enabled');
         Mage::getSingleton('adminhtml/session')->addWarning($message);
     }
     return $observer;
 }
Exemplo n.º 27
0
 /**
  * Checks if a update request is necessary and performs it if so.
  *
  * @param Varien_Event_Observer $observer
  */
 public function checkVersion($observer)
 {
     $user = $observer->getUser();
     $extra = unserialize($user->getExtra());
     $lastCheck = Mage::getStoreConfig('payment/barzahlen/last_check');
     if (isset($extra['configState']['payment_barzahlen']) && $extra['configState']['payment_barzahlen'] == 1) {
         if ($lastCheck == null || $lastCheck < strtotime("-1 week")) {
             $config = new Mage_Core_Model_Config();
             $config->saveConfig('payment/barzahlen/last_check', time(), 'default', 0);
             Mage::getConfig()->cleanCache();
             $barzahlen = Mage::getSingleton('barzahlen/barzahlen');
             $check = Mage::getSingleton('barzahlen/api_version');
             $shopId = $barzahlen->getConfigData('shop_id') != null ? $barzahlen->getConfigData('shop_id') : $barzahlen->getConfigData('shop_id', 1);
             if ($check->isNewVersionAvailable($shopId, 'Magento', Mage::getVersion(), (string) Mage::getConfig()->getNode()->modules->ZerebroInternet_Barzahlen->version)) {
                 Mage::getSingleton('core/session')->addNotice(sprintf(Mage::helper('barzahlen')->__('bz_adm_now_available'), $check->getNewPluginVersion(), $check->getNewPluginUrl()));
             }
         }
     }
 }
 /**
  * AutoCreate and map datafields.
  */
 public function setupdatafieldsAction()
 {
     $result = array('errors' => false, 'message' => '');
     $websiteParam = $this->getRequest()->getParam('website', 0);
     $website = Mage::app()->getWebsite($websiteParam);
     $apiModel = Mage::helper('ddg')->getWebsiteApiClient($website->getId());
     $redirectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit', array('section' => 'connector_data_mapping'));
     if (!$apiModel) {
         Mage::getSingleton('adminhtml/session')->addNotice('Please enable api first.');
     } else {
         // get all possible datatifileds
         $datafields = Mage::getModel('ddg_automation/connector_datafield')->getContactDatafields();
         foreach ($datafields as $key => $datafield) {
             $response = $apiModel->postDataFields($datafield);
             //ignore existing datafields message
             if (isset($response->message) && $response->message != Dotdigitalgroup_Email_Model_Apiconnector_Client::API_ERROR_DATAFIELD_EXISTS) {
                 $result['errors'] = true;
                 $result['message'] .= ' Datafield ' . $datafield['name'] . ' - ' . $response->message . '</br>';
             } else {
                 if ($websiteParam) {
                     $scope = 'websites';
                     $scopeId = $website->getId();
                 } else {
                     $scope = 'default';
                     $scopeId = '0';
                 }
                 /**
                  * map the succesful created datafield
                  */
                 $config = new Mage_Core_Model_Config();
                 $config->saveConfig('connector_data_mapping/customer_data/' . $key, strtoupper($datafield['name']), $scope, $scopeId);
                 Mage::helper('ddg')->log('successfully connected : ' . $datafield['name']);
             }
         }
         if ($result['errors']) {
             Mage::getSingleton('adminhtml/session')->addNotice($result['message']);
         } else {
             Mage::getConfig()->cleanCache();
             Mage::getSingleton('adminhtml/session')->addSuccess('All Datafields Created And Mapped.');
         }
     }
     $this->_redirectUrl($redirectUrl);
 }
Exemplo n.º 29
0
 /**
  * @param Varien_Event_Observer $o
  */
 public function saveConfig(Varien_Event_Observer $o)
 {
     if (Mage::app()->getRequest()->getParam('store')) {
         $scope = 'store';
     } elseif (Mage::app()->getRequest()->getParam('website')) {
         $scope = 'website';
     } else {
         $scope = "default";
     }
     $store = is_null($o->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $o->getEvent()->getStore();
     if (!Mage::helper('ebizmarts_mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::GENERAL_ACTIVE, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::helper('ebizmarts_mandrill')->useTransactionalService()) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, $scope, $store);
         $config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ENABLE_POPUP, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::getStoreConfig('customer/address/dob_show')) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
     if (!Mage::getStoreConfig('customer/address/dob_show', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_ACTIVE, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
     if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Wishlist', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::WISHLIST_ACTIVE, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
     if (Mage::getStoreConfig('advanced/modules_disable_output/Mage_Review', $store)) {
         $config = new Mage_Core_Model_Config();
         $config->saveConfig(Ebizmarts_Autoresponder_Model_Config::REVIEW_ACTIVE, false, $scope, $store);
         Mage::getConfig()->cleanCache();
     }
 }
<?php

/**
 * Created by PhpStorm.
 * User: juancarlosc
 */
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$model = new Mage_Core_Model_Config();
// disable guest checkout
$model->saveConfig('customer/startup/redirect_dashboard', 0, 'default', 0);
$installer->endSetup();