/** * Retrieve field dependencies * * @param array $dependencies * @param string $storeCode * @param string $fieldPrefix * @return array */ public function getDependencies($dependencies, $storeCode, $fieldPrefix = '') { $output = array(); foreach ($dependencies as $depend) { /* @var array $depend */ $fieldId = $fieldPrefix . array_pop($depend['dependPath']); $depend['dependPath'][] = $fieldId; $dependentId = implode('_', $depend['dependPath']); $shouldAddDependency = true; $dependentValue = $depend['value']; if (isset($depend['separator'])) { $dependentValue = explode($depend['separator'], $dependentValue); } /** @var Mage_Backend_Model_Config_Structure_Element_Field $dependentField */ $dependentField = $this->_fieldLocator->getElement($depend['id']); /* * If dependent field can't be shown in current scope and real dependent config value * is not equal to preferred one, then hide dependence fields by adding dependence * based on not shown field (not rendered field) */ if (false == $dependentField->isVisible()) { $valueInStore = $this->_application->getStore($storeCode)->getConfig($dependentField->getPath($fieldPrefix)); if (is_array($dependentValue)) { $shouldAddDependency = !in_array($valueInStore, $dependentValue); } else { $shouldAddDependency = $dependentValue != $valueInStore; } } if ($shouldAddDependency) { $output[$dependentId] = $dependentValue; } } return $output; }
/** * @param array $tag * @param Definition $definition */ private function processTag($tag, Definition $definition) { foreach ($tag as $attribute) { if (isset($attribute['key'])) { $configValue = $this->_mageApp->getStore()->getConfig($attribute['key']); $definition->addArgument($configValue); } } }
/** * Process redirect (R) and permanent redirect (RP) * * @return Mage_Core_Model_Url_Rewrite_Request */ protected function _processRedirectOptions() { $isPermanentRedirectOption = $this->_rewrite->hasOption('RP'); $external = substr($this->_rewrite->getTargetPath(), 0, 6); if ($external === 'http:/' || $external === 'https:') { $destinationStoreCode = $this->_app->getStore($this->_rewrite->getStoreId())->getCode(); $this->_setStoreCodeCookie($destinationStoreCode); $this->_sendRedirectHeaders($this->_rewrite->getTargetPath(), $isPermanentRedirectOption); } $targetUrl = $this->_request->getBaseUrl() . '/' . $this->_rewrite->getTargetPath(); $storeCode = $this->_app->getStore()->getCode(); if (Mage::getStoreConfig('web/url/use_store') && !empty($storeCode)) { $targetUrl = $this->_request->getBaseUrl() . '/' . $storeCode . '/' . $this->_rewrite->getTargetPath(); } if ($this->_rewrite->hasOption('R') || $isPermanentRedirectOption) { $this->_sendRedirectHeaders($targetUrl, $isPermanentRedirectOption); } $queryString = $this->_getQueryString(); if ($queryString) { $targetUrl .= '?' . $queryString; } $this->_request->setRequestUri($targetUrl); $this->_request->setPathInfo($this->_rewrite->getTargetPath()); return $this; }
/** * @param GetResponseEvent $event */ public function onKernelRequestSetStore(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType() && $this->app) { $store = $this->storeResolver->resolve($event->getRequest()); if (false !== $store) { // keep default store in case manual override fails $defaultStore = $this->app->getStore()->getCode(); $this->app->setCurrentStore($store); try { // try to load the store $this->app->getStore(); } catch (\Mage_Core_Model_Store_Exception $e) { $this->app->setCurrentStore($defaultStore); } } } }
/** * Get rate for current row, 1 by default * * @param $row * @return float|int */ protected function _getRate($row) { if ($rate = $this->getColumn()->getRate()) { return floatval($rate); } if ($rate = $row->getData($this->getColumn()->getRateField())) { return floatval($rate); } return $this->_app->getStore()->getBaseCurrency()->getRate($this->_getCurrencyCode($row)); }
/** * Retrieve default currency for selected store, website or website group * * @param Mage_Core_Controller_Request_Http $request * @return string */ public function getDefaultCurrency(Mage_Core_Controller_Request_Http $request) { if ($request->getParam('store')) { $store = $request->getParam('store'); $currencyCode = $this->_app->getStore($store)->getBaseCurrencyCode(); } else { if ($request->getParam('website')) { $website = $request->getParam('website'); $currencyCode = $this->_app->getWebsite($website)->getBaseCurrencyCode(); } else { if ($request->getParam('group')) { $group = $request->getParam('group'); $currencyCode = $this->_app->getGroup($group)->getWebsite()->getBaseCurrencyCode(); } else { $currencyCode = $this->_app->getStore()->getBaseCurrencyCode(); } } } return $currencyCode; }
/** * Fix url path for category in layer navigation * * @param Varien_Event_Observer $object * @return Varien_Event_Observer */ public function addUrlSuffixToUrlAlias(Varien_Event_Observer $object) { $matchCodes = array(Enterprise_Catalog_Model_Category::URL_REWRITE_ENTITY_TYPE => Mage_Catalog_Helper_Category::XML_PATH_CATEGORY_URL_SUFFIX, Enterprise_Catalog_Model_Product::URL_REWRITE_ENTITY_TYPE => Mage_Catalog_Helper_Product::XML_PATH_PRODUCT_URL_SUFFIX); $rewrite = $object->getUrlRewrite(); if ($rewrite) { foreach ($matchCodes as $type => $xmlPath) { if ($rewrite->getEntityType() == $type) { $store = $this->_app->getStore($rewrite->getStoreId()); $suffix = $store->getConfig($xmlPath); $urlPath = $rewrite->getRequestPath(); if ($suffix) { $urlPath .= '.' . $suffix; } $rewrite->setRequestPath($urlPath); break; } } $object->setUrlRewrite($rewrite); } return $object; }
/** * Before collecting item totals, check that all items * in the quote are available to be fulfilled. * * @param Varien_Event_Observer * @return self */ public function handleBeforeCollectTotals(Varien_Event_Observer $observer) { try { $quote = $observer->getEvent()->getQuote(); $this->quantityService->checkQuoteInventory($quote); } catch (EbayEnterprise_Inventory_Exception_Quantity_Collector_Exception $e) { $this->logger->logException($e, $this->logContext->getMetaData(__CLASS__, [], $e)); $this->logger->warning('Caught the following exception: {exception_message}.', $this->logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); } catch (EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception $e) { $this->logger->logException($e, $this->logContext->getMetaData(__CLASS__, [], $e)); $this->logger->warning('Caught the following exception: {exception_message}.', $this->logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); if ($this->app->getStore()->isAdmin()) { // Handling admin exception here because it is not // being caught in the admin controller causing it // to display exception traces in the page. return $this->handleAdminOrderException($e, $quote); } // Continue to throw the exception in the frontend and let // the frontend controller handle it. throw $e; } return $this; }
/** * Get tax management url * * @return string */ public function getInfoUrl() { return $this->_app->getStore()->getConfig(Mage_Tax_Model_Config::XML_PATH_TAX_NOTIFICATION_URL); }
/** * Retrieve regions data json * * @param int|null $storeId * @return array() */ public function getRegionJsonByStore($storeId = null) { Varien_Profiler::start('TEST: ' . __METHOD__); if (!$this->_regionJson) { $store = $this->_app->getStore($storeId); $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . (string) $store->getId(); if ($this->_app->useCache('config')) { $json = $this->_app->loadCache($cacheKey); } if (empty($json)) { $regions = $this->_getRegions($storeId); $helper = $this->_factory->getHelper('core'); $json = $helper->jsonEncode($regions); if ($this->_app->useCache('config')) { $this->_app->saveCache($json, $cacheKey, array('config')); } } $this->_regionJson = $json; } Varien_Profiler::stop('TEST: ' . __METHOD__); return $this->_regionJson; }
/** * Retrieve attribute source value for search * * @deprecated since version 1.13.2 * @param int $attributeId * @param mixed $value * @param int $storeId * @return mixed */ protected function _getAttributeValue($attributeId, $value, $storeId) { /** @var $attribute Mage_Eav_Model_Attribute */ $attribute = $this->_getSearchableAttribute($attributeId); if (!$attribute->getIsSearchable()) { return null; } if ($attribute->usesSource()) { $attribute->setStoreId($storeId); $value = $attribute->getSource()->getIndexOptionText($value); if (is_array($value)) { $value = implode($this->_separator, $value); } elseif (empty($value)) { $inputType = $attribute->getFrontend()->getInputType(); if ($inputType == 'select' || $inputType == 'multiselect') { return null; } } } elseif ($attribute->getBackendType() == 'datetime') { $value = $this->_getStoreDate($storeId, $value); } else { $inputType = $attribute->getFrontend()->getInputType(); if ($inputType == 'price') { $value = $this->_app->getStore($storeId)->roundPrice($value); } } $value = preg_replace("#\\s+#siu", ' ', trim(strip_tags($value))); return $value; }
/** * Check if warning about conflicting FPT configuration should be shown * * @return bool */ public function isConflictingFptTaxConfigurationSettingsIgnored() { return (bool) $this->_app->getStore()->getConfig(Mage_Tax_Model_Config::XML_PATH_TAX_NOTIFICATION_FPT_CONFIGURATION); }
/** * Set current VDE theme */ protected function _setTheme() { $themeId = $this->_backendSession->getData('theme_id'); if ($themeId !== null) { $path = $this->_designPackage->getConfigPathByArea(Mage_Core_Model_App_Area::AREA_FRONTEND); $this->_application->getStore()->setConfig($path, $themeId); } }
/** * Get base URL path by type * * @param string $type * @return string */ public static function getBaseUrl($type = Mage_Core_Model_Store::URL_TYPE_LINK, $secure = null) { return AO::$_app->getStore()->getBaseUrl($type, $secure); }
/** * Checks whether crawler is enabled for given store * * @param int $storeId * @return null|string */ protected function _isCrawlerEnabled($storeId) { return (bool) (string) $this->_app->getStore($storeId)->getConfig(self::XML_PATH_CRAWLER_ENABLED); }
/** * Check if do not show notification about wrong discount settings * * @return bool */ public function isWrongDiscountSettingsIgnored() { return (bool) $this->_app->getStore()->getConfig(Mage_Tax_Model_Config::XML_PATH_TAX_NOTIFICATION_DISCOUNT); }
/** * @expectedException Mage_Core_Model_Store_Exception */ public function testGetNotExistingStore() { $this->_mageModel->getStore(100); }
/** * Get captcha image base URL * * @param mixed $website * @return string */ public function getImgUrl($website = null) { return $this->_app->getStore()->getBaseUrl('media') . 'captcha' . '/' . $this->_app->getWebsite($website)->getCode() . '/'; }