/** * @param Store $store * @return \NostoAccount */ public function build(Store $store) { $metaData = new \NostoAccount(); try { $metaData->setTitle(implode(' - ', [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()])); $metaData->setName(substr(sha1(rand()), 0, 8)); $metaData->setFrontPageUrl(\NostoHttpRequest::replaceQueryParamInUrl('___store', $store->getCode(), $store->getBaseUrl(UrlInterface::URL_TYPE_WEB))); $metaData->setCurrency(new \NostoCurrencyCode($store->getBaseCurrencyCode())); $lang = substr($store->getConfig('general/locale/code'), 0, 2); $metaData->setLanguage(new \NostoLanguageCode($lang)); $lang = substr($this->_localeResolver->getLocale(), 0, 2); $metaData->setOwnerLanguage(new \NostoLanguageCode($lang)); $owner = $this->_accountOwnerMetaBuilder->build(); $metaData->setOwner($owner); $billing = $this->_accountBillingMetaBuilder->build($store); $metaData->setBilling($billing); } catch (\NostoException $e) { $this->_logger->error($e, ['exception' => $e]); } return $metaData; }
/** * 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); } } }
/** * Gets the absolute preview URL to the current store view front page. * The preview url includes "nostodebug=true" parameter. * * @param Mage_Core_Model_Store $store the store to get the url for. * * @return string the url. */ public function getPreviewUrlFront(Mage_Core_Model_Store $store) { $url = Mage::getUrl('', array('_store' => $store->getId(), '_store_to_url' => true)); return NostoHttpRequest::replaceQueryParamInUrl('nostodebug', 'true', $url); }
/** * Returns the authorize url to the oauth2 server. * * @return string the url. */ public function getAuthorizationUrl() { $url = NostoHttpRequest::buildUri(self::$baseUrl . self::PATH_AUTH, array('{cid}' => $this->clientId, '{uri}' => urlencode($this->redirectUrl), '{sco}' => implode(' ', $this->scopes), '{iso}' => $this->language->getCode())); if ($this->account) { $url = NostoHttpRequest::replaceQueryParamInUrl('merchant', $this->account->getName(), $url); } return $url; }
/** * Gets the absolute preview URL to the current store view front page. * The preview url includes "nostodebug=true" parameter. * * @param Mage_Core_Model_Store $store the store to get the url for. * * @return string the url. */ public function getPreviewUrlFront(Mage_Core_Model_Store $store) { $url = Mage::getUrl('', $this->getUrlOptions($store)); return NostoHttpRequest::replaceQueryParamInUrl('nostodebug', 'true', $url); }
/** * Tests the "replaceQueryParamInUrl" helper method. */ public function testHttpRequestReplaceQueryParamInUrl() { $url = NostoHttpRequest::replaceQueryParamInUrl('param1', 'replaced_first', sprintf('http://localhost:%d/tmp/?param1=first¶m2=second', self::CURL_TEST_PORT)); $this->assertEquals(sprintf('http://localhost:%d/tmp/?param1=replaced_first¶m2=second', self::CURL_TEST_PORT), $url); }
/** * 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; }
/** * Adds the `nostodebug` parameter to a url. * * @param string $url the url. * @return string the updated url. */ public function addNostoDebugParamToUrl($url) { return \NostoHttpRequest::replaceQueryParamInUrl('nostodebug', 'true', $url); }