protected function _displayTable(OutputInterface $output, \Mage_Core_Model_Store $store) { $this->writeSection($output, 'Current design setting on store: ' . $store->getWebsite()->getCode() . '/' . $store->getCode()); $storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true); $storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store)); $this->getHelper('table')->setHeaders(array('Parameter', 'Value'))->renderByFormat($output, $storeInfoLines); return $this; }
/** * Create a Klevu Webstore using the API for the given Magento store. * * @param $customer_id * @param Mage_Core_Model_Store $store * @param bool $test_mode * * @return array An array with the following keys: * success: boolean value indicating whether the operation was successful. * webstore: (success only) Varien_Object containing Webstore information. * message: message to be displayed to the user. */ public function createWebstore($customer_id, Mage_Core_Model_Store $store, $test_mode = false) { $name = sprintf("%s - %s - %s", $store->getWebsite()->getName(), $store->getName(), $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); $language = Mage::helper("klevu_search")->getStoreLanguage($store); $timezone = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); // Convert $test_mode to string $test_mode = $test_mode ? "true" : "false"; $response = Mage::getModel("klevu_search/api_action_addwebstore")->execute(array("customerId" => $customer_id, "storeName" => $name, "language" => $language, "timezone" => $timezone, "testMode" => $test_mode)); if ($response->isSuccessful()) { $webstore = new Varien_Object(array("store_name" => $name, "js_api_key" => $response->getJsApiKey(), "rest_api_key" => $response->getRestApiKey(), "test_account_enabled" => $test_mode)); return array("success" => true, "webstore" => $webstore, "message" => $response->getMessage()); } else { return array("success" => false, "message" => $response->getMessage()); } }
/** * Create a Klevu Webstore using the API for the given Magento store. * * @param $customer_id * @param Mage_Core_Model_Store $store * @param bool $test_mode * * @return array An array with the following keys: * success: boolean value indicating whether the operation was successful. * webstore: (success only) Varien_Object containing Webstore information. * message: message to be displayed to the user. */ public function createWebstore($customer_id, Mage_Core_Model_Store $store, $test_mode = false) { $name = sprintf("%s - %s - %s - %s", $store->getWebsite()->getName(), $store->getCode(), $store->getName(), $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); $language = Mage::helper("klevu_search")->getStoreLanguage($store); $timezone = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); $country = $store->getConfig(Mage_Core_Helper_Data::XML_PATH_DEFAULT_COUNTRY); $locale = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE); $version = $this->getVersion(); // Convert $test_mode to string $test_mode = $test_mode ? "true" : "false"; $response = Mage::getModel("klevu_search/api_action_addwebstore")->execute(array("customerId" => $customer_id, "storeName" => $name, "language" => $language, "timezone" => $timezone, "version" => $version, "country" => $country, "locale" => $locale, "testMode" => $test_mode)); if ($response->isSuccessful()) { $webstore = new Varien_Object(array("store_name" => $name, "js_api_key" => $response->getJsApiKey(), "rest_api_key" => $response->getRestApiKey(), "test_account_enabled" => $test_mode, "hosted_on" => $response->getHostedOn(), "cloud_search_url" => $response->getCloudSearchUrl(), "analytics_url" => $response->getAnalyticsUrl(), "js_url" => $response->getJsUrl(), "rest_hostname" => $response->getRestUrl())); return array("success" => true, "webstore" => $webstore, "message" => $response->getMessage()); } else { return array("success" => false, "message" => $response->getMessage()); } }
/** * Loads the meta data for the given store. * * @param Mage_Core_Model_Store $store the store view to load the data for. */ public function loadData(Mage_Core_Model_Store $store) { /* @var Nosto_Tagging_Helper_Data $helper */ $helper = Mage::helper('nosto_tagging'); $this->_title = $helper->cleanUpAccountTitle($store->getWebsite()->getName() . ' - ' . $store->getGroup()->getName() . ' - ' . $store->getName()); $this->_name = substr(sha1(rand()), 0, 8); if (!$helper->getUsePrettyProductUrls()) { $this->_frontPageUrl = NostoHttpRequest::replaceQueryParamInUrl('___store', $store->getCode(), $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); } else { $this->_frontPageUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); } $this->_currencyCode = $store->getBaseCurrencyCode(); $this->_languageCode = substr($store->getConfig('general/locale/code'), 0, 2); $this->_ownerLanguageCode = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2); /** @var Nosto_Tagging_Model_Meta_Account_Owner $owner */ $owner = Mage::getModel('nosto_tagging/meta_account_owner'); $owner->loadData(); $this->_owner = $owner; /** @var Nosto_Tagging_Model_Meta_Account_Billing $billing */ $billing = Mage::getModel('nosto_tagging/meta_account_billing'); $billing->loadData($store); $this->_billing = $billing; $this->_useCurrencyExchangeRates = !$helper->multiCurrencyDisabled($store); if (!$helper->multiCurrencyDisabled($store)) { $this->_defaultPriceVariationId = $store->getBaseCurrencyCode(); } else { $this->_defaultPriceVariationId = ""; } $storeLocale = $store->getConfig('general/locale/code'); $currencyCodes = $store->getAvailableCurrencyCodes(true); if (is_array($currencyCodes) && count($currencyCodes) > 0) { /** @var Nosto_Tagging_Helper_Currency $currencyHelper */ $currencyHelper = Mage::helper('nosto_tagging/currency'); foreach ($currencyCodes as $currencyCode) { $this->_currencies[$currencyCode] = $currencyHelper->getCurrencyObject($storeLocale, $currencyCode); } } }
/** * Set store to customer * * @param Mage_Core_Model_Store $store * @return Mage_Customer_Model_Customer */ public function setStore(Mage_Core_Model_Store $store) { $this->setStoreId($store->getId()); $this->setWebsiteId($store->getWebsite()->getId()); return $this; }
/** * @param Mage_Core_Model_Store $store * @return string */ protected function _getFullStoreName($store) { if (!isset($this->_fullStoreNames[$store->getId()])) { $fullStoreName = $store->getWebsite()->getName() . ' / ' . $store->getGroup()->getName() . ' / ' . $store->getName(); $this->_fullStoreNames[$store->getId()] = $fullStoreName; } return $this->_fullStoreNames[$store->getId()]; }
/** * Setup an API session for the given store. Sets the store and session ID on self. Returns * true on success or false if Product Sync is disabled, store is not configured or the * session API call fails. * * @param Mage_Core_Model_Store $store * * @return bool */ protected function setupSession(Mage_Core_Model_Store $store) { $config = Mage::helper('klevu_search/config'); if (!$config->isProductSyncEnabled($store->getId())) { $this->log(Zend_Log::INFO, sprintf("Disabled for %s (%s).", $store->getWebsite()->getName(), $store->getName())); return null; } $api_key = $config->getRestApiKey($store->getId()); if (!$api_key) { $this->log(Zend_Log::INFO, sprintf("No API key found for %s (%s).", $store->getWebsite()->getName(), $store->getName())); return null; } $response = Mage::getModel('klevu_search/api_action_startsession')->execute(array('api_key' => $api_key, 'store' => $store)); if ($response->isSuccessful()) { $this->addData(array('store' => $store, 'session_id' => $response->getSessionId())); return true; } else { $this->log(Zend_Log::ERR, sprintf("Failed to start a session for %s (%s): %s", $store->getWebsite()->getName(), $store->getName(), $response->getMessage())); if ($response instanceof Klevu_Search_Model_Api_Response_Empty) { /*$this->notify( Mage::helper('klevu_search')->__( "Product Sync failed for %s (%s): Could not contact Klevu.", $store->getWebsite()->getName(), $store->getName() ) );*/ } else { $this->notify(Mage::helper('klevu_search')->__("Product Sync failed for %s (%s): %s", $store->getWebsite()->getName(), $store->getName(), $response->getMessage())); } return false; } }
/** * Loads the meta data for the given store. * * @param Mage_Core_Model_Store $store the store view to load the data for. */ public function loadData(Mage_Core_Model_Store $store) { $this->_title = $store->getWebsite()->getName() . ' - ' . $store->getGroup()->getName() . ' - ' . $store->getName(); $this->_name = substr(sha1(rand()), 0, 8); $this->_frontPageUrl = NostoHttpRequest::replaceQueryParamInUrl('___store', $store->getCode(), $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); $this->_currencyCode = $store->getBaseCurrencyCode(); $this->_languageCode = substr($store->getConfig('general/locale/code'), 0, 2); $this->_ownerLanguageCode = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2); /** @var Nosto_Tagging_Model_Meta_Account_Owner $owner */ $owner = Mage::getModel('nosto_tagging/meta_account_owner'); $owner->loadData($store); $this->_owner = $owner; /** @var Nosto_Tagging_Model_Meta_Account_Billing $billing */ $billing = Mage::getModel('nosto_tagging/meta_account_billing'); $billing->loadData($store); $this->_billing = $billing; }