/** * @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(); } }
/** * 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); }
protected function _loadSecondConfig() { $config = new \Mage_Core_Model_Config(); $config->loadBase(); //get app/etc $this->_secondConfig = \Mage::getConfig()->loadModulesConfiguration('config.xml', $config); }
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; }
/** * Get renderer for Mime-Type specified in Accept header of request. * * @return Mage_Webapi_Controller_Response_Rest_RendererInterface * @throws Mage_Webapi_Exception * @throws LogicException */ public function get() { $acceptTypes = $this->_request->getAcceptTypes(); $availableRenderers = (array) $this->_applicationConfig->getNode(self::XML_PATH_WEBAPI_RESPONSE_RENDERS); if (!is_array($acceptTypes)) { $acceptTypes = array($acceptTypes); } foreach ($acceptTypes as $acceptType) { foreach ($availableRenderers as $rendererConfig) { $rendererType = (string) $rendererConfig->type; if ($acceptType == $rendererType || $acceptType == current(explode('/', $rendererType)) . '/*' || $acceptType == '*/*') { $rendererClass = (string) $rendererConfig->model; break 2; } } } if (!isset($rendererClass)) { /** If server does not have renderer for any of the accepted types it SHOULD send 406 (not acceptable). */ throw new Mage_Webapi_Exception($this->_helper->__('Server cannot understand Accept HTTP header media type.'), Mage_Webapi_Exception::HTTP_NOT_ACCEPTABLE); } $renderer = $this->_objectManager->get($rendererClass); if (!$renderer instanceof Mage_Webapi_Controller_Response_Rest_RendererInterface) { throw new LogicException('The renderer must implement "Mage_Webapi_Controller_Response_Rest_RendererInterface".'); } return $renderer; }
public function setUp() { $this->_config = new Mage_Core_Model_Config(<<<XML <config> <global> <cache> <types> <single_tag> <label>Tag One</label> <description>This is Tag One</description> <tags>tag_one</tags> </single_tag> <multiple_tags> <label>Tags One and Two</label> <description>These are Tags One and Two</description> <tags>tag_one,tag_two</tags> </multiple_tags> </types> </cache> </global> </config> XML ); $this->_helper = $this->getMock('Mage_Core_Helper_Data', array('__')); $this->_helper->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_config->setOptions(array('cache_dir' => __DIR__, 'etc_dir' => __DIR__)); $this->_cacheFrontend = $this->getMock('Zend_Cache_Core', array('load', 'test', 'save', 'remove', 'clean', '_getHelper')); $this->_requestProcessor = $this->getMock('stdClass', array('extractContent')); $this->_model = new Mage_Core_Model_Cache(array('config' => $this->_config, 'helper' => $this->_helper, 'frontend' => $this->_cacheFrontend, 'backend' => 'BlackHole', 'request_processors' => array($this->_requestProcessor))); }
/** * Initialize reader instance */ protected function setUp() { $path = array(__DIR__, '..', '..', '_files', 'acl.xml'); $path = realpath(implode(DIRECTORY_SEPARATOR, $path)); $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); $this->_configMock->expects($this->any())->method('getModuleDir')->with('etc', 'Mage_Webapi')->will($this->returnValue(realpath(__DIR__ . '/../../../../../../../../../app/code/core/Mage/Webapi/etc'))); $this->_reader = new Mage_Webapi_Model_Authorization_Config_Reader($this->_configMock, array($path)); }
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); } }
/** * Initialize dependencies * * @param Magento_ObjectManager $objectManager * @param Mage_Core_Model_Config $config * @param Mage_Core_Model_Translate $translator */ public function __construct(Magento_ObjectManager $objectManager, Mage_Core_Model_Config $config, Mage_Core_Model_Translate $translator) { $this->_objectManager = $objectManager; $this->_config = $config; $this->_translator = $translator; $this->_configFiles = $this->_config->getModuleConfigurationFiles('validation.xml'); $this->_initializeDefaultTranslator(); }
/** * Redirect type options * * @return array */ public function toOptionArray() { $values = (array) $this->_config->getNode('redirect_type', 'default'); if (isset($values['@attributes'])) { unset($values['@attributes']); } return $values; }
/** * Reader object initialization * * @return Magento_Acl_Config_Reader */ protected function _getReader() { if (null === $this->_reader) { $aclResourceFiles = $this->_getAclResourceFiles(); $this->_reader = $this->_config->getModelInstance('Magento_Acl_Config_Reader', $aclResourceFiles); } return $this->_reader; }
/** * Search a code pool for modules and enable them * * @param string $codePool * @param OutputInterface $output * * @return int|void */ protected function enableCodePool($codePool, OutputInterface $output) { $modules = $this->config->getNode('modules')->asArray(); foreach ($modules as $module => $data) { if (isset($data['codePool']) && $data['codePool'] == $codePool) { $this->enableModule($module, $output); } } }
/** *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); } }
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(); } }
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); } }
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); }
/** * @param mixed $data * @param array $map * @dataProvider constructorDataProvider */ public function testConstructor($data, $map) { //TODO: We should not use mocks in integration tests /** @var Magento_ObjectManager_Zend|PHPUnit_Framework_MockObject_MockObject $objectManagerMock */ $objectManagerMock = $this->getMock('Magento_ObjectManager_Zend', array('create', 'get'), array(), '', false); $objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap(array($map, array('Mage_Core_Model_Config_Base', array(), true, new Mage_Core_Model_Config_Base())))); $this->_model = new Mage_Core_Model_Config($objectManagerMock, $data); $this->assertInstanceOf('Mage_Core_Model_Config_Options', $this->_model->getOptions()); }
/** * Init router from config * * @param Mage_Core_Model_Config $config Config * @return void */ public function initFromConfig(Mage_Core_Model_Config $config) { $routerConfig = $config->getNode('global/messenger/publish_router'); if (!$routerConfig) { return; } foreach ($routerConfig->children() as $_route) { $this->addMap(new Varien_Object($_route->criterion->asArray()), $_route->queue); } }
/** * Set up before test */ protected function setUp() { $helper = new Magento_Test_Helper_ObjectManager($this); $this->_config = $this->getMockBuilder('Mage_Core_Model_Config')->disableOriginalConstructor()->setMethods(array('getModuleConfigurationFiles'))->getMock(); $this->_readerFactory = $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config_Reader_Factory')->disableOriginalConstructor()->setMethods(array('createReader'))->getMock(); $this->_configReader = $this->getMockBuilder('Magento_Acl_Config_Reader')->disableOriginalConstructor()->setMethods(array('getAclResources'))->getMock(); $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Config', array('config' => $this->_config, 'readerFactory' => $this->_readerFactory)); $this->_config->expects($this->any())->method('getModuleConfigurationFiles')->will($this->returnValue(array())); $this->_readerFactory->expects($this->any())->method('createReader')->will($this->returnValue($this->_configReader)); }
/** * 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); }
/** * Apply all updater to value * * @param mixed $value * @param array $updaters * @throws InvalidArgumentException * @return mixed */ public function applyUpdaters($value, array $updaters = array()) { foreach ($updaters as $updater) { /** @var Mage_Core_Model_Layout_Argument_UpdaterInterface $updaterInstance */ $updaterInstance = $this->_objectFactory->getModelInstance($updater); if (false === $updaterInstance instanceof Mage_Core_Model_Layout_Argument_UpdaterInterface) { throw new InvalidArgumentException($updater . ' should implement Mage_Core_Model_Layout_Argument_UpdaterInterface'); } $value = $updaterInstance->update($value); } return $value; }
/** * Get argument handler factory by given type * @param string $type * @return Mage_Core_Model_Layout_Argument_HandlerFactoryInterface * @throws InvalidArgumentException */ public function getArgumentHandlerFactoryByType($type) { if (false == is_string($type)) { throw new InvalidArgumentException('Passed invalid argument handler type'); } if (!isset($this->_handlerFactories[$type])) { throw new InvalidArgumentException('Argument handler ' . $type . ' is not exists'); } /** @var $handlerFactory Mage_Core_Model_Layout_Argument_HandlerFactoryInterface */ $handlerFactory = $this->_objectFactory->getModelInstance($this->_handlerFactories[$type]); return $handlerFactory; }
/** * Prepares "edit" block. * * @return Mage_Core_Block_Abstract */ protected function _prepareLayout() { $type = $this->getRequest()->getParam('type'); if (!empty($type)) { $blockClassName = (string) $this->_config->getNode(self::XML_PATH_REDIRECT_TYPE_BLOCK . $type); if (!empty($blockClassName)) { $editBlock = $this->getLayout()->createBlock($blockClassName); $this->setChild('edit', $editBlock); } } return parent::_prepareLayout(); }
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); } } }
/** * @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.'); } }
/** * Init observers from Magento config * * @param Mage_Core_Model_Config $config Config * @return Oggetto_Messenger_Model_Event_Observer */ public function initFromConfig(Mage_Core_Model_Config $config) { $configNodes = $config->getNode()->xpath('global/messenger/event_observers/*'); if (!$configNodes) { return $this; } $observers = []; foreach ($configNodes as $_observer) { $observers[$_observer->getName()] = Mage::getSingleton('messenger/di')->get((string) $_observer->class); } $this->setObservers($observers); return $this; }
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>."); } }
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; }
/** * Get file handler by process ID * * @param $processId * @return Mage_Index_Model_Process_File */ public function getFile($processId) { if (!isset($this->_fileHandlers[$processId])) { $file = $this->_fileFactory->createFromArray(); $varDirectory = $this->_configuration->getVarDir('locks'); $file->setAllowCreateFolders(true); $file->open(array('path' => $varDirectory)); $fileName = 'index_process_' . $processId . '.lock'; $file->streamOpen($fileName); $file->streamWrite(date('r')); $this->_fileHandlers[$processId] = $file; } return $this->_fileHandlers[$processId]; }
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(); } }