Ejemplo n.º 1
0
 /**
  * Saves a Nosto account to PS config.
  * Also handles any attached API tokens.
  *
  * @param NostoAccount $account the account to save.
  * @param null|int $id_lang the ID of the language to set the account name for.
  * @return bool true if the save was successful, false otherwise.
  */
 public function save(NostoAccount $account, $id_lang)
 {
     /** @var NostoTaggingHelperConfig $helper_config */
     $helper_config = Nosto::helper('nosto_tagging/config');
     $success = $helper_config->saveAccountName($account->getName(), $id_lang);
     if ($success) {
         foreach ($account->getTokens() as $token) {
             $success = $success && $helper_config->saveToken($token->getName(), $token->getValue(), $id_lang);
         }
     }
     return $success;
 }
Ejemplo n.º 2
0
 /**
  * Saves the account and the associated api tokens for the store view scope.
  *
  * @param NostoAccount               $account the account to save.
  * @param Mage_Core_Model_Store|null $store   the store view to save it for.
  *
  * @return bool true on success, false otherwise.
  */
 public function save(NostoAccount $account, Mage_Core_Model_Store $store = null)
 {
     if ($store === null) {
         $store = Mage::app()->getStore();
     }
     if ((int) $store->getId() < 1) {
         return false;
     }
     /** @var Mage_Core_Model_Config $config */
     $config = Mage::getModel('core/config');
     $config->saveConfig(self::XML_PATH_ACCOUNT, $account->getName(), 'stores', $store->getId());
     $tokens = array();
     foreach ($account->getTokens() as $token) {
         $tokens[$token->getName()] = $token->getValue();
     }
     $config->saveConfig(self::XML_PATH_TOKENS, json_encode($tokens), 'stores', $store->getId());
     Mage::app()->getCacheInstance()->cleanType('config');
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Saves the account and the associated api tokens for the store view scope.
  *
  * @param NostoAccount               $account the account to save.
  * @param Mage_Core_Model_Store|null $store   the store view to save it for.
  *
  * @return bool true on success, false otherwise.
  */
 public function save(NostoAccount $account, Mage_Core_Model_Store $store = null)
 {
     if ($store === null) {
         $store = Mage::app()->getStore();
     }
     if ((int) $store->getId() < 1) {
         return false;
     }
     /** @var Mage_Core_Model_Config $config */
     $config = Mage::getModel('core/config');
     $config->saveConfig(self::XML_PATH_ACCOUNT, $account->getName(), 'stores', $store->getId());
     $tokens = array();
     foreach ($account->getTokens() as $token) {
         $tokens[$token->getName()] = $token->getValue();
     }
     $config->saveConfig(self::XML_PATH_TOKENS, json_encode($tokens), 'stores', $store->getId());
     /** @var Nosto_Tagging_Helper_Cache $helper */
     $helper = Mage::helper('nosto_tagging/cache');
     $helper->flushCache();
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Saves the account and the associated api tokens for the store.
  *
  * @param \NostoAccount $account the account to save.
  * @param Store $store the store.
  *
  * @return bool true on success, false otherwise.
  */
 public function saveAccount(\NostoAccount $account, Store $store)
 {
     if ((int) $store->getId() < 1) {
         return false;
     }
     $tokens = array();
     foreach ($account->getTokens() as $token) {
         $tokens[$token->getName()] = $token->getValue();
     }
     $this->_config->save(self::XML_PATH_ACCOUNT, $account->getName(), ScopeInterface::SCOPE_STORES, $store->getId());
     $this->_config->save(self::XML_PATH_TOKENS, json_encode($tokens), ScopeInterface::SCOPE_STORES, $store->getId());
     $store->resetConfig();
     return true;
 }