/**
  * @param Result $result
  * @param \Mage_Core_Model_Store $store
  * @param string $baseUrl setting
  */
 protected function checkSettings(Result $result, \Mage_Core_Model_Store $store, $baseUrl)
 {
     $errorMessage = 'Wrong hostname configured. <info>Hostname must contain a dot</info>';
     $host = parse_url($baseUrl, PHP_URL_HOST);
     $isValid = (bool) strstr($host, '.');
     $result->setStatus($isValid);
     if ($isValid) {
         $result->setMessage('<info>' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - OK');
     } else {
         $result->setMessage('<error>Invalid ' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> ' . $errorMessage . '</error>');
     }
 }
 /**
  * @param Result                 $result
  * @param \Mage_Core_Model_Store $store
  * @param string                 $baseUrl      setting
  * @param string                 $cookieDomain setting
  */
 protected function checkSettings(Result $result, \Mage_Core_Model_Store $store, $baseUrl, $cookieDomain)
 {
     $errorMessage = 'cookie-domain and ' . $this->class . ' base-URL do not match';
     if (strlen($cookieDomain)) {
         $isValid = $this->validateCookieDomainAgainstUrl($cookieDomain, $baseUrl);
         $result->setStatus($isValid);
         if ($isValid) {
             $result->setMessage('<info>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - OK</info>');
         } else {
             $result->setMessage('<error>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - ERROR: ' . $errorMessage . '</error>');
         }
     } else {
         $result->setMessage('<info>Empty cookie Domain (' . $this->class . ') of Store: <comment>' . $store->getCode() . '</comment> - OK</info>');
     }
 }
 /**
  * @param Mage_Core_Model_Store $store
  */
 protected function _flushAllSpecialPrices($store)
 {
     /** @var Mage_Catalog_Model_Resource_Product_Collection $products */
     $products = Mage::getResourceModel('catalog/product_collection')->setStoreId($store->getId())->addAttributeToFilter('special_from_date', array('lteq' => now(true)))->addAttributeToFilter(array(array('attribute' => 'special_to_date', 'gteq' => now(true)), array('attribute' => 'special_to_date', 'null' => true)))->addWebsiteFilter($store->getWebsiteId());
     $size = $products->getSize();
     if ($size) {
         $msg = sprintf('process store %s and %s product(s) with all special prices', $store->getCode(), $size);
         Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array(array($this, 'iteratorCallback')), array('size' => $size, 'msg' => $msg, 'store' => $store));
         echo PHP_EOL;
     }
 }
Example #4
0
 /**
  * Gets the absolute preview URL to the current store view category page.
  * The category is the first one found in the database for the store.
  * 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 getPreviewUrlCategory(Mage_Core_Model_Store $store)
 {
     $rootCategoryId = (int) $store->getRootCategoryId();
     $collection = Mage::getModel('catalog/category')->getCollection()->addFieldToFilter('is_active', 1)->addFieldToFilter('path', array('like' => "1/{$rootCategoryId}/%"))->addAttributeToSelect('*')->setPageSize(1)->setCurPage(1);
     foreach ($collection as $category) {
         /** @var Mage_Catalog_Model_Category $category */
         $url = $category->getUrl();
         $url = NostoHttpRequest::replaceQueryParamInUrl('___store', $store->getCode(), $url);
         return NostoHttpRequest::replaceQueryParamInUrl('nostodebug', 'true', $url);
     }
     return '';
 }
Example #5
0
 /**
  * @return string
  */
 protected function _parseException($node, \Mage_Core_Model_Store $store)
 {
     $exception = (string) \Mage::getConfig()->getNode($node . self::THEMES_EXCEPTION, AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode());
     if (empty($exception)) {
         return '';
     }
     $exceptions = unserialize($exception);
     $result = array();
     foreach ($exceptions as $expression) {
         $result[] = 'Matched Expression: ' . $expression['regexp'];
         $result[] = 'Value: ' . $expression['value'];
     }
     return implode("\n", $result);
 }
Example #6
0
 /**
  * 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());
     }
 }
Example #7
0
 protected function _initWriters(Mage_Core_Model_Store $oStore, $vFeedname, Mage_Core_Model_Config_Element $oConfig)
 {
     foreach ($oConfig->output->children() as $oOutputFile) {
         switch (trim($oOutputFile->format)) {
             case 'csv':
                 $oWriter = Mage::getModel('aligent_feeds/writer_csv')->init($oStore->getCode(), $vFeedname, $oOutputFile, $oConfig->fields);
                 if ($oWriter instanceof Aligent_Feeds_Model_Writer_Abstract) {
                     $this->_oWriters[] = $oWriter;
                 }
                 break;
             case 'xml':
                 $oWriter = Mage::getModel('aligent_feeds/writer_xml')->init($oStore->getCode(), $vFeedname, $oOutputFile, $oConfig->fields);
                 if ($oWriter instanceof Aligent_Feeds_Model_Writer_Abstract) {
                     $this->_oWriters[] = $oWriter;
                 }
                 break;
         }
     }
     return $this;
 }
 /**
  * @param $config
  * @return Payone_Settings_Data_ConfigFile_Abstract|Payone_Settings_Data_ConfigFile_Shop
  */
 protected function generateSettingsShop($config)
 {
     /** @var $shopConfig Payone_Settings_Data_ConfigFile_Shop */
     $shopConfig = $this->getSettingsClass('shop');
     $helper = $this->helper();
     $shopCode = $this->store->getCode();
     $shopName = $this->store->getName();
     $shopConfig->setCode($shopCode);
     $shopConfig->setName($shopName);
     $systemConfig = $this->generateSettingsSystem();
     $shopConfig->setSystem($systemConfig);
     $globalConfig = $this->generateSettingsGlobal($config);
     $shopConfig->setGlobal($globalConfig);
     $clearingtypesConfig = $this->generateSettingsClearingtypes($config);
     $shopConfig->setClearingtypes($clearingtypesConfig);
     $protectConfig = $this->generateSettingsProtect($config);
     $shopConfig->setProtect($protectConfig);
     $miscConfig = $this->generateSettingsMisc($config);
     $shopConfig->setMisc($miscConfig);
     return $shopConfig;
 }
 /**
  * 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);
         }
     }
 }
Example #10
0
 /**
  * Returns dir for feed file storage
  * @param Mage_Core_Model_Store $store
  *
  * @return string
  */
 protected function _getFeedDir($store)
 {
     if (Mage::getBaseDir('tmp')) {
         $dir = Mage::getBaseDir('tmp') . DIRECTORY_SEPARATOR . $store->getCode();
         if (!file_exists($dir)) {
             mkdir($dir, 0777);
         }
         if (!is_dir($dir) || !is_writable($dir)) {
             throw new Varien_Exception('Unable to find writable feed catalog');
         }
     }
     return $dir;
 }
Example #11
0
 /**
  * Create a domain from a given store, or a default domain if none is given.
  *
  * @param null|\Mage_Core_Model_Store $store
  * @return string
  */
 public function createDomain(\Mage_Core_Model_Store $store = null)
 {
     $rv = implode('.', array($this->getProject(), $this->getEnvironment(), $this->getDomain()));
     if (isset($store) && $store->isAdmin() === false) {
         $storeCode = $store->getCode();
         if ($storeCode !== $store::DEFAULT_CODE) {
             $rv = "{$storeCode}-{$rv}";
         }
     }
     return $rv;
 }
Example #12
0
 /**
  * Init Staging Store Views
  *
  * @param Varien_Data_Form $fieldset
  * @param Mage_Core_Model_Store $storeView
  * @param Mage_Core_Model_Website $stagingWebsite
  * @return Enterprise_Staging_Block_Manage_Staging_Edit_Tabs_Website
  */
 protected function _initStoreView($fieldset, $storeView, $stagingWebsite = null)
 {
     $_shift = str_repeat(' ', 6);
     if (!$stagingWebsite) {
         $_id = $storeView->getId();
         $websiteId = $storeView->getWebsiteId();
         $fieldset->addField('master_store_use_' . $_id, 'checkbox', array('label' => $_shift . $storeView->getName(), 'name' => "websites[{$websiteId}][stores][{$_id}][use]", 'value' => $storeView->getId(), 'checked' => true));
         $fieldset->addField('master_store_id_' . $_id, 'hidden', array('label' => Mage::helper('enterprise_staging')->__('Master Store ID'), 'name' => "websites[{$websiteId}][stores][{$_id}][master_store_id]", 'value' => $storeView->getId()));
         $fieldset->addField('master_store_code_' . $_id, 'hidden', array('label' => Mage::helper('enterprise_staging')->__('Master Store Code'), 'name' => "websites[{$websiteId}][stores][{$_id}][master_store_code]", 'value' => $storeView->getCode()));
         $fieldset->addField('staging_store_code_' . $_id, 'hidden', array('label' => Mage::helper('enterprise_staging')->__('Staging Store Code'), 'name' => "websites[{$websiteId}][stores][{$_id}][code]", 'value' => Mage::helper('enterprise_staging/store')->generateStoreCode($storeView->getCode())));
         $fieldset->addField('staging_store_name_' . $_id, 'hidden', array('label' => Mage::helper('enterprise_staging')->__('Staging Store Name'), 'name' => "websites[{$websiteId}][stores][{$_id}][name]", 'value' => $storeView->getName()));
     } else {
         $fieldset->addField('staging_store_' . $storeView->getId(), 'label', array('label' => $_shift . $storeView->getName()));
     }
     return $this;
 }
 private function _saveStoreConfigItems(array $configs, Mage_Core_Model_Store $store)
 {
     try {
         if (!$store->getId()) {
             throw new Exception($this->__('Store does not exist'));
         }
         if (!empty($configs)) {
             foreach ($configs as $config) {
                 if (isset($config['encrypted']) && $config['encrypted'] == 1) {
                     $config['value'] = Mage::helper('core')->encrypt($config['value']);
                 }
                 // Save config
                 $this->_checkAndSaveConfig($config['path'], $config['value'], 'stores', $store->getId(), $store->getCode());
             }
         }
     } catch (Exception $e) {
         $this->log($e->getMessage());
     }
 }
Example #14
0
 /**
  * Builds the absolute store front url for the product page.
  *
  * The url includes the "___store" GET parameter in order for the Nosto
  * crawler to distinguish between stores that do not have separate domains
  * or paths.
  *
  * @param Mage_Catalog_Model_Product $product the product model.
  * @param Mage_Core_Model_Store      $store the store model.
  *
  * @return string
  */
 protected function buildUrl(Mage_Catalog_Model_Product $product, Mage_Core_Model_Store $store)
 {
     // Unset the cached url first, as it won't include the `___store` param
     // if it's cached. We need to define the specific store view in the url
     // in case the same domain is used for all sites.
     $product->unsetData('url');
     return $product->getUrlInStore(array('_nosid' => true, '_ignore_category' => true, '_store' => $store->getCode()));
 }
Example #15
0
 /**
  * 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;
 }
Example #16
0
 /**
  * Process the given store.
  *
  * @param UrlTransformer $transformer
  * @param \Mage_Core_Model_Store $store
  * @param OutputInterface $output
  * @return void
  */
 protected function processStore(UrlTransformer $transformer, \Mage_Core_Model_Store $store, OutputInterface $output)
 {
     if ($output->getVerbosity() >= $output::VERBOSITY_VERBOSE) {
         $output->writeln("<comment>{$store->getCode()}</comment> " . "<info>{$store->getName()}</info> " . "- {$store->getFrontendName()}");
     }
     $output->writeln($transformer->createDomain($store));
     $rewrites = $transformer->rewriteStore($store);
     if ($output->getVerbosity() >= $output::VERBOSITY_VERBOSE) {
         foreach ($rewrites as $xpath => $baseUrl) {
             $output->writeln("\t<info>{$xpath}</info> => {$baseUrl}");
         }
     }
 }