/** * Retrieve information about current Magento installation * * @return array */ public function info() { $result = array(); $result['magento_edition'] = Mage::getEdition(); $result['magento_version'] = Mage::getVersion(); return $result; }
/** * Retrieve Magento edition * * @return string */ public function getMagentoEdition() { if (method_exists('Mage', 'getEdition')) { // getEdition is only available after Magento CE Version 1.7.0.0 $edition = Mage::getEdition(); switch ($edition) { case Mage::EDITION_COMMUNITY: $edition = 'CE'; break; case Mage::EDITION_ENTERPRISE: $edition = 'EE'; break; case Mage::EDITION_PROFESSIONAL: $edition = 'PE'; break; case Mage::EDITION_GO: $edition = 'GO'; break; } } else { // Check for different Licensetypes to get Magento-Edition $path = Mage::getBaseDir(); if (file_exists($path . DS . 'LICENSE_EE.txt')) { $edition = 'EE'; } elseif (file_exists($path . DS . 'LICENSE_PRO.html')) { $edition = 'PE'; } else { $edition = 'CE'; } } return $edition; }
private function _createOrUpdateAttribute($code, $data) { $attribute = $this->_getAttribute($code); $canSave = false; if (!$attribute) { $this->log($this->__('Creating Attribute %s', $code)); $attribute = Mage::getModel('catalog/resource_eav_attribute'); $attribute->setData('attribute_code', $code); $canSave = true; $data = array_replace_recursive($this->_getAttributeDefaultSettings(), $data); $data['backend_type'] = $attribute->getBackendTypeByInput($data['frontend_input']); $data['source_model'] = Mage::helper('catalog/product')->getAttributeSourceModelByInputType($data['frontend_input']); $data['backend_model'] = Mage::helper('catalog/product')->getAttributeBackendModelByInputType($data['frontend_input']); } foreach ($data as $key => $value) { // Skip store labels to be processed after if ($key == 'store_labels') { continue; } // YAML will pass product types as an array which needs to be imploded if ($key == "product_types") { $key = "apply_to"; $value = implode(",", $value); } // YAML will pass options as an array which will require to be added differently if ($key == "options") { continue; } // Skip setting search_weight if not enterprise if ($key == "search_weight" && Mage::getEdition() != Mage::EDITION_ENTERPRISE) { continue; } if ($attribute->getId() && $attribute->getData($key) == $value) { continue; } $attribute->setData($key, $value); $this->log($this->__('Setting attribute "%s" %s with %s', $code, $key, $value)); $canSave = true; } unset($key); unset($value); if (!$attribute->getEntityTypeId()) { $attribute->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId()); $attribute->setIsUserDefined(1); } try { if ($canSave) { $attribute->save(); $this->log($this->__('Saved Attribute %s', $code)); } if ($data['options']) { $this->_maintainAttributeOptions($attribute, $data['options']); } if ($data['store_labels']) { $this->_maintainAttributeStoreLabels($attribute, $data['store_labels']); } } catch (Exception $e) { throw $e; } }
private function nodeToArray(Varien_Data_Tree_Node $node, $mediaUrl, $baseUrl) { $result = array(); $thumbnail = ''; try { $thumbImg = $node->getThumbnail(); if ($thumbImg != null) { $thumbnail = $mediaUrl . 'catalog/category/' . $node->getThumbnail(); } } catch (Exception $e) { } $result['category_id'] = $node->getId(); $result['image'] = $mediaUrl . 'catalog/category/' . $node->getImage(); $result['thumbnail'] = $thumbnail; $result['description'] = strip_tags($node->getDescription()); $result['parent_id'] = $node->getParentId(); $result['name'] = $node->getName(); $result['is_active'] = $node->getIsActive(); $result['children'] = array(); if (method_exists('Mage', 'getEdition') && Mage::getEdition() == Mage::EDITION_COMMUNITY) { $result['url_path'] = $baseUrl . $node->getData('url_path'); } else { $category = Mage::getModel('catalog/category')->load($node->getId()); $result['url_path'] = $category->getUrl(); } foreach ($node->getChildren() as $child) { $result['children'][] = $this->nodeToArray($child, $mediaUrl, $baseUrl); } return $result; }
public static function getEdition() { if (!self::$_edition) { $configEE = BP . "/app/code/core/Enterprise/Enterprise/etc/config.xml"; if (!file_exists($configEE)) { self::$_edition = 'ce'; } else { $xml = @simplexml_load_file($configEE, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml !== false) { $package = (string) $xml->default->design->package->name; if (!$package) { $package = strtolower(Mage::getEdition()); } if ($package == 'enterprise') { self::$_edition = 'ee'; } else { self::$_edition = 'pe'; } } else { self::$_edition = 'unknown'; } } } return self::$_edition; }
/** * get Magento version * * @return string */ public function getMageVersion() { $mageVersion = Mage::getVersion(); if (is_callable('Mage::getEdition')) { $mageVersion = Mage::getEdition() . ' ' . $mageVersion; } return $mageVersion; }
/** * Get Feed URL * @return string * @throws Zend_Uri_Exception */ public function getFeedUrl() { $version = Mage::getConfig()->getModuleConfig('PayEx_MasterPass')->version->asArray(); $params = array('site_url' => Mage::getStoreConfig('web/unsecure/base_url'), 'installed_version' => $version, 'mage_ver' => Mage::getVersion(), 'edition' => Mage::getEdition()); $uri = Zend_Uri::factory(self::URL_NEWS); $uri->addReplaceQueryParameters($params); return $uri->getUri(); }
/** * Display search result */ public function indexAction() { $query = Mage::helper('catalogsearch')->getQuery(); /* @var $query Mage_CatalogSearch_Model_Query */ $query->setStoreId(Mage::app()->getStore()->getId()); if ($query->getQueryText() != '') { if (Mage::helper('catalogsearch')->isMinQueryLength()) { $query->setId(0)->setIsActive(1)->setIsProcessed(1); } else { if ($query->getId()) { $query->setPopularity($query->getPopularity() + 1); } else { $query->setPopularity(1); } if ($query->getRedirect()) { $query->save(); $this->getResponse()->setRedirect($query->getRedirect()); return; } else { $query->prepare(); } } Mage::helper('catalogsearch')->checkNotes(); $this->loadLayout(); // apply custom ajax layout if ($this->getRequest()->isAjax()) { $update = $this->getLayout()->getUpdate(); $update->addHandle('catalog_category_layered_ajax_layer'); } $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('checkout/session'); // return json formatted response for ajax if ($this->getRequest()->isAjax()) { $listing = $this->getLayout()->getBlock('search_result_list')->toHtml(); if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) { $block = $this->getLayout()->getBlock('enterprisesearch.leftnav'); } else { $block = $this->getLayout()->getBlock('catalogsearch.leftnav'); } $layer = $block->toHtml(); // Fix urls that contain '___SID=U' $urlModel = Mage::getSingleton('core/url'); $listing = $urlModel->sessionUrlVar($listing); $layer = $urlModel->sessionUrlVar($layer); $response = array('listing' => $listing, 'layer' => $layer); $this->getResponse()->setHeader('Content-Type', 'application/json', true); $this->getResponse()->setBody(json_encode($response)); } else { $this->renderLayout(); } if (!Mage::helper('catalogsearch')->isMinQueryLength()) { $query->save(); } } else { $this->_redirectReferer(); } }
/** * Retrieves Magento Edition * * @return string */ public function getEdition() { if (method_exists('Mage', 'getEdition')) { $systemEdition = Mage::getEdition(); if (isset($this->_editionMapping[$systemEdition])) { return $this->_editionMapping[$systemEdition]; } } return $this->getBehaviourEdition(); }
/** * Define magento version and edition */ protected function _verifyMagento() { include $this->_magentoDir . 'app/Mage.php'; $this->_version = Mage::getVersion(); if (method_exists('Mage', 'getEdition')) { $this->_edition = Mage::getEdition(); } else { $this->_edition = file_exists($this->_magentoDir . 'app/etc/modules/Enterprise_Enterprise.xml') ? 'Enterprise' : 'Community'; } }
/** * @return array */ public function getCoreVersionInfo() { $core = array(); $core['store_id'] = $this->getStoreId(); $core['mage_version'] = Mage::getVersion(); if (method_exists('Mage', 'getEdition')) { $core['mage_edition'] = Mage::getEdition(); } return $core; }
private function validateDesignConfig() { if (method_exists('Mage', 'getEdition')) { $editionVersion = [Mage::EDITION_ENTERPRISE => '1.14.0', Mage::EDITION_PROFESSIONAL => '1.14.0', Mage::EDITION_COMMUNITY => '1.9.0']; if (!version_compare(Mage::getVersion(), $editionVersion[Mage::getEdition()], '>=')) { $this->markTestSkipped('Does not supported in this Magento version'); } } return false; }
/** * Render block HTML * * @return string */ protected function _toHtml() { $configHelper = $this->getConfigHelper(); // Module disabled if (!$configHelper->extensionEnabled()) { return ''; } if (Mage::getEdition() === Mage::EDITION_ENTERPRISE) { // Recreate the widget parameter cache on FPC cleared or just created if (!$this->getFullPageCacheEnvironment() && $this->getUniqueId()) { $id = RapidCampaign_Promotions_Model_Fpc_Placeholder::CACHE_PREFIX . $this->getUniqueId() . '_params'; Enterprise_PageCache_Model_Cache::getCacheInstance()->save(serialize($this->getData()), $id); } } if (!$this->validateRules()) { return ''; } /** @var RapidCampaign_Promotions_Model_Storage $promotionsStorage */ $promotionsStorage = Mage::getModel('rapidcampaign_promotions/storage'); try { $promotionModel = $promotionsStorage->getPromotionsModel(); } catch (Exception $e) { $promotionModel = $promotionsStorage->getCachedPromotionsModel(); } $promotion = $promotionModel->load($this->getData('promotion')); // Promotion does not exist if ($promotion->isEmpty()) { return ''; } $urlParams = $this->getUrlParams($promotion); $promotionData = $promotion->getData(); $iframeUrl = $promotionData['embed_url'] . '?' . http_build_query($urlParams); $iframeWidth = $promotionData['width'] ?: self::IFRAME_WIDTH; $iframeHeight = $promotionData['height'] ?: self::IFRAME_HEIGHT; if ($configHelper->testModeEnabled()) { $embedScript = self::IFRAME_JS_TEST_BASE_URL; } else { $embedScript = self::IFRAME_JS_BASE_URL; } $isModalEnabled = $this->getData('modal_enabled'); $hideDiv = $isModalEnabled ? "display:none" : ""; if (preg_match('/sales/i', $promotionData['promotion_category'])) { $embedScript .= self::IFRAME_SALES_EMBED; $iframeString = sprintf('<div class="_rc_iframe %s" style="%s" data-url="%s" data-width="%s" data-height="%s"></div>', $this->getIframeClass($this->getUniqueId()), $hideDiv, $iframeUrl, $iframeWidth, $iframeHeight); } else { $embedScript .= self::IFRAME_MARKETING_EMBED; $iframeString = sprintf('<div class="_rc_miframe %s" style="%s" data-url="%s"></div>', $this->getIframeClass($this->getUniqueId()), $hideDiv, $iframeUrl); } $jsString = sprintf('<script type="text/javascript" src="%s"></script>', $embedScript); $html = $iframeString . $jsString; if ($isModalEnabled) { $html .= $this->getPromotionModalJs($promotion); } return $html; }
protected function _verifyMagento($pathToMagentoBaseDir) { include $pathToMagentoBaseDir . 'app/Mage.php'; $this->_version = \Mage::getVersion(); if (method_exists('Mage', 'getEdition')) { $this->_edition = \Mage::getEdition(); } else { preg_match('/^1\\.(\\d+)\\./', $this->_version, $matches); $majorRelease = $matches[1]; $this->_edition = $majorRelease < 7 ? 'Community' : 'Enterprise'; } echo 'Analyzing Magento ' . $this->_version . ' (' . $this->_edition . ' Edition)...' . PHP_EOL; }
public function isAvailableVersion() { $mage = new Mage(); if (!is_callable(array($mage, 'getEdition'))) { $edition = 'Community'; } else { $edition = Mage::getEdition(); } unset($mage); if ($edition == 'Enterprise' && $this->_version == 'CE') { return false; } return true; }
private function getMagento() { $this->log("===== MAGENTO ====="); $this->log("version: " . Mage::getVersion()); $this->log("edition: " . Mage::getEdition()); $this->log("base_path: " . $this->_basepath); $this->log("secure_frontend: " . (Mage::getStoreConfig('web/secure/use_in_frontend') == 1 ? 'yes' : 'no')); $this->log("store_name: " . Mage::getStoreConfig('general/store_information/name')); if (defined('COMPILER_INCLUDE_PATH')) { $this->log("compilation: enabled"); } else { $this->log("compilation: disabled"); } }
/** * Get gift wrapping tax class id * * @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo|Mage_Sales_Model_Quote_Address $object * @return int */ protected function _getGwTaxClassId($object) { if (Mage::getEdition() !== Mage::EDITION_ENTERPRISE) { return 0; } if (!$object->getGwPrice() && !$object->getGwItemsPrice() && !$object->getGwPrintedCardPrice()) { return 0; } if ($object instanceof Mage_Sales_Model_Quote_Address) { $storeId = $object->getQuote()->getStoreId(); } else { $storeId = $object->getStoreId(); } return $this->_getWrappingTaxClass($storeId); }
/** * @param $api_url * @param $api_key * @param bool $body * @return mixed */ private function intelipostRequest($api_url, $api_key, $entity_action, $request = false) { $mgversion = Mage::getEdition() . " " . Mage::getVersion(); $s = curl_init(); curl_setopt($s, CURLOPT_TIMEOUT, 5000); curl_setopt($s, CURLOPT_URL, $api_url . $entity_action); curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: {$api_key}", "platform: {$mgversion}", "plugin: 1.1.0")); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_ENCODING, ""); curl_setopt($s, CURLOPT_RETURNTRANSFER, 1); curl_setopt($s, CURLOPT_POSTFIELDS, $request); $response = curl_exec($s); curl_close($s); return $response; }
/** * Before rendering html, but after trying to load cache * * @return Mage_Core_Block_Abstract * @see Mage_Core_Block_Template::_beforeToHtml * @since 2014/11/02 added CE 1.9 support * @since 2014/11/02 added proper directory separators to support windows based systems * @since 2014/11/02 fixed that enterprise versions have been compared like there were community versions (still no really EE support yet) */ protected function _beforeToHtml() { // Set latest available template as default $this->setTemplate('ds' . DIRECTORY_SEPARATOR . 'privatesales' . DIRECTORY_SEPARATOR . 'login_ce19.phtml'); // Use older template depending on magento version (is there a layout xml based solution for that?) $e = method_exists('Mage', 'getEdition') ? Mage::getEdition() : 'Community'; $v = Mage::getVersion(); // Use CE 1.4 - 1.6.2 compatible template if ($e == 'Community' && version_compare($v, '1.7') < 0) { $this->setTemplate('ds' . DIRECTORY_SEPARATOR . 'privatesales' . DIRECTORY_SEPARATOR . 'login_ce14_15_16.phtml'); } elseif ($e == 'Community' && version_compare($v, '1.9') < 0) { $this->setTemplate('ds' . DIRECTORY_SEPARATOR . 'privatesales' . DIRECTORY_SEPARATOR . 'login_ce17_18.phtml'); } return $this; }
public function getFeedUrl() { if (is_null($this->_feedUrl)) { $this->_feedUrl = Mage::helper('alekseon_modulesConflictDetector')->getAlekseonUrl() . '/rss/magento_rss.xml'; $query = '?utm_source=' . urlencode(Mage::getStoreConfig('web/unsecure/base_url')); $query .= '&utm_medium=' . urlencode('Magento Connect'); if (method_exists('Mage', 'getEdition')) { $query .= '&utm_content=' . urlencode(Mage::getEdition() . ' ' . Mage::getVersion()); } else { $query .= '&utm_content=' . urlencode(Mage::getVersion()); } $query .= '&utm_term=' . urlencode(implode(',', $this->_getAlekseonInstalledModules())); $this->_feedUrl .= $query; } return $this->_feedUrl; }
public function grabData() { $generalData = array(); $generalData['module_name'] = 'Sage Pay Suite'; //change it according to the module $generalData['host'] = Mage::getUrl(); $generalData['server_ip'] = Mage::helper('core/http')->getServerAddr(); $generalData['vendorname'] = Mage::getModel('sagepaysuite/sagePayServer')->getConfigData('vendor'); $generalData['magento_version'] = Mage::getVersion(); if (method_exists('Mage', 'getEdition')) { // Fix for earlier Magento versions $generalData['magento_edition'] = Mage::getEdition(); } $generalData['module_version'] = (string) Mage::getConfig()->getNode('modules/Ebizmarts_SagePaySuite/version'); if ($code = Mage::getSingleton('adminhtml/config_data')->getStore()) { $generalData['store_id'] = Mage::getModel('core/store')->load($code)->getId(); } elseif ($code = Mage::getSingleton('adminhtml/config_data')->getWebsite()) { $website_id = Mage::getModel('core/website')->load($code)->getId(); $generalData['store_id'] = Mage::app()->getWebsite($website_id)->getDefaultStore()->getId(); } else { $generalData['store_id'] = 0; } $integrations = array('sagepayform', 'sagepaypaypal', 'sagepaydirectpro', 'sagepayserver', 'sagepaydirectpro_moto', 'sagepayserver_moto'); $integrationData = array(); foreach ($integrations as $integration) { $path = 'payment/' . $integration . '/active'; if (Mage::getStoreConfig($path, $generalData['store_id'])) { $integrationData[$integration] = array(); $path = 'payment/' . $integration . '/mode'; //$integrationData[$integration]['integration'] = $integration; $integrationData[$integration]['mode'] = Mage::getStoreConfig($path, $generalData['store_id']); $path = 'payment/' . $integration . '/vendor'; $vendor = Mage::getStoreConfig($path, $generalData['store_id']); if (!empty($vendor) && $vendor != $generalData['vendorname']) { $integrationData[$integration]['vendorname'] = $vendor; } } } $data = array(); $data['general'] = $generalData; $data['integrations'] = $integrationData; return $data; }
public function testExecute() { $application = $this->getApplication(); $application->add(new ScriptCommand()); $application->setAutoExit(false); $command = $this->getApplication()->find('script'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), 'filename' => __DIR__ . '/_files/test.mr')); // Check pre defined vars $edition = is_callable(array('\\Mage', 'getEdition')) ? \Mage::getEdition() : 'Community'; $this->assertContains('contao.edition: ' . $edition, $commandTester->getDisplay()); $this->assertContains('contao.root: ' . $this->getApplication()->getContaoRootFolder(), $commandTester->getDisplay()); $this->assertContains('contao.version: ' . \Mage::getVersion(), $commandTester->getDisplay()); $this->assertContains('conrun.version: ' . $this->getApplication()->getVersion(), $commandTester->getDisplay()); $this->assertContains('code', $commandTester->getDisplay()); $this->assertContains('foo.sql', $commandTester->getDisplay()); $this->assertContains('BAR: foo.sql.gz', $commandTester->getDisplay()); $this->assertContains('Contao Websites', $commandTester->getDisplay()); $this->assertContains('web/secure/base_url', $commandTester->getDisplay()); $this->assertContains('web/seo/use_rewrites => 1', $commandTester->getDisplay()); }
public function categoryDirective($construction) { // This directive only works if we have a category! if (!($category = Mage::registry('category'))) { $category = Mage::registry('current_category'); } if (is_object($category) && $category->getId()) { $params = $this->_getIncludeParameters($construction[2]); // Only if we have an attribute if (isset($params['attr']) || isset($params['attribute'])) { $attr = isset($params['attr']) ? $params['attr'] : $params['attribute']; $data = $category->getDataUsingMethod($attr); if ($attr == Mbiz_TrackingTags_Model_Config::CATEGORY_URL_KEY_ATTRIBUTE_CODE && Mage::getEdition() == Mage::EDITION_ENTERPRISE) { $data = $this->_getEnterpriseUrlKey($category); } return Mage::helper('core')->jsQuoteEscape($data, '\''); } // Products ? if (isset($params['products'])) { $attributesProducts = explode(',', $params['products']); $typeId = isset($params['type']) ? $params['type'] : 'configurable'; $limit = isset($params['limit']) ? (int) $params['limit'] : 5; $productsCollection = $category->getProductCollection()->addCategoryFilter($category)->addAttributeToFilter('type_id', $typeId)->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->addAttributeToSelect($attributesProducts); $productsCollection->getSelect()->limit($limit); $_products = array(); foreach ($productsCollection as $product) { $_product = array(); foreach ($attributesProducts as $attr) { $_product[$attr] = $product->getDataUsingMethod($attr); } $_products[] = $_product; unset($_product); } unset($productsCollection); return $this->_exportDisplayItems($_products, $params, $attributesProducts); } } return ''; }
/** * @param string $searchFolder * * @return bool */ protected function _search($searchFolder) { if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) { $this->output->writeln('<debug>Search for Magento in folder <info>' . $searchFolder . '</info></debug>'); } if (!is_dir($searchFolder . '/app')) { return false; } $finder = Finder::create(); $finder->ignoreUnreadableDirs(true)->depth(0)->followLinks()->name('Mage.php')->name('bootstrap.php')->name('autoload.php')->in($searchFolder . '/app'); if ($finder->count() > 0) { $files = iterator_to_array($finder, false); /* @var $file \SplFileInfo */ if (count($files) == 2) { // Magento 2 has bootstrap.php and autoload.php in app folder $this->_magentoMajorVersion = \N98\Magento\Application::MAGENTO_MAJOR_VERSION_2; } $this->_magentoRootFolder = $searchFolder; if (is_callable(array('\\Mage', 'getEdition'))) { $this->_magentoEnterprise = \Mage::getEdition() == 'Enterprise'; } else { $this->_magentoEnterprise = is_dir($this->_magentoRootFolder . '/app/code/core/Enterprise'); } if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) { $this->output->writeln('<debug>Found Magento in folder <info>' . $this->_magentoRootFolder . '</info></debug>'); } return true; } return false; }
public function versAction() { $mage = Mage::getVersion(); $ext = (string) Mage::getConfig()->getNode()->modules->Autocompleteplus_Autosuggest->version; try { $num_of_products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter(Mage::app()->getStore()->getStoreId())->getSize(); } catch (Exception $e) { $num_of_products = -1; } if (method_exists('Mage', 'getEdition')) { $edition = Mage::getEdition(); } else { $edition = 'Community'; } $helper = Mage::helper('autocompleteplus_autosuggest'); $uuid = $helper->getKey(); $site_url = $helper->getConfigDataByFullPath('web/unsecure/base_url'); $store_id = Mage::app()->getStore()->getStoreId(); $result = array('mage' => $mage, 'ext' => $ext, 'num_of_products' => $num_of_products, 'edition' => $edition, 'uuid' => $uuid, 'site_url' => $site_url, 'store_id' => $store_id); $post = $this->getRequest()->getParams(); if (array_key_exists('modules', $post)) { $get_modules = $post['modules']; } else { $get_modules = false; } if ($get_modules) { try { $modules_array = array(); foreach (Mage::getConfig()->getNode('modules')->children() as $name => $module) { if ($module->codePool != 'core' && $module->active == 'true') { $modules_array[$name] = $module; } } } catch (Exception $e) { $modules_array = array(); } $result['modules'] = $modules_array; } echo json_encode($result); die; }
public function testIsApplicableToQuoteFeatureModelTrue() { $versionInfo = Mage::getVersionInfo(); if (array_key_exists('minor', $versionInfo) && (Mage::getEdition() === Mage::EDITION_COMMUNITY && $versionInfo['minor'] > '7') || Mage::getEdition() === Mage::EDITION_ENTERPRISE && $versionInfo['minor'] > '13') { $featureModelMock = $this->getModelMock('ops/payment_features_zeroAmountAuth', array('isCCAndZeroAmountAuthAllowed')); $featureModelMock->expects($this->any())->method('isCCAndZeroAmountAuthAllowed')->will($this->returnValue(true)); $this->replaceByMock('model', 'ops/payment_features_zeroAmountAuth', $featureModelMock); $helperMock = $this->getHelperMock('ops/version', array('canUseApplicableForQuote')); $helperMock->expects($this->any())->method('canUseApplicableForQuote')->will($this->returnValue(true)); $this->replaceByMock('helper', 'ops/version', $helperMock); $quote = Mage::getModel('sales/quote'); $this->assertTrue($this->_model->isApplicableToQuote($quote, '1')); } }
/** * Render block HTML * * @return string */ protected function _toHtml() { /** @var RapidCampaign_Promotions_Helper_Config $configHelper */ $configHelper = Mage::helper('rapidcampaign_promotions/config'); // Module disabled if (!$configHelper->extensionEnabled()) { return ''; } if (Mage::getEdition() === Mage::EDITION_ENTERPRISE) { // Recreate the widget parameter cache on FPC cleared or just created if (!$this->getFullPageCacheEnvironment() && $this->getUniqueId()) { $id = RapidCampaign_Promotions_Model_Fpc_Placeholder::CACHE_PREFIX . $this->getUniqueId() . '_params'; Enterprise_PageCache_Model_Cache::getCacheInstance()->save(serialize($this->getData()), $id); } } // The rules not valid if (!$this->validateRules()) { return ''; } /** @var RapidCampaign_Promotions_Model_Storage $promotionsStorage */ $promotionsStorage = Mage::getModel('rapidcampaign_promotions/storage'); try { $promotionModel = $promotionsStorage->getPromotionsModel(); } catch (Exception $e) { $promotionModel = $promotionsStorage->getCachedPromotionsModel(); } $promotion = $promotionModel->load($this->getData('promotion')); // Promotion does not exist if ($promotion->isEmpty()) { return ''; } $promotionData = $promotion->getData(); /** @var Mage_Customer_Model_Session $sessionModel */ $sessionModel = Mage::getSingleton('customer/session'); $urlParams = array('promo_id' => $promotionData['slug'], 'customer_group' => $sessionModel->getCustomerGroupId(), 'cart_value' => $this->getCartTotal()); if ($sessionModel->isLoggedIn()) { $customer = $sessionModel->getCustomer(); if ($customer->getFirstname()) { $urlParams['first_name'] = $customer->getFirstname(); } if ($customer->getLastname()) { $urlParams['last_name'] = $customer->getLastname(); } } // Parameter encryption enabled if ($configHelper->encryptionEnabled()) { $urlParams = $this->encryptParameters($urlParams); } $iframeUrl = $promotionData['embed_url'] . '?' . http_build_query($urlParams); $iframeWidth = $promotionData['width'] ?: self::IFRAME_WIDTH; $iframeHeight = $promotionData['height'] ?: self::IFRAME_HEIGHT; if ($configHelper->testModeEnabled()) { $embedScript = self::IFRAME_JS_TEST_BASE_URL; } else { $embedScript = self::IFRAME_JS_BASE_URL; } if (preg_match('/sales/i', $promotionData['promotion_category'])) { $embedScript .= self::IFRAME_SALES_EMBED; $iframeString = sprintf('<div class="_rc_iframe" data-url="%s" data-width="%s" data-height="%s"></div>', $iframeUrl, $iframeWidth, $iframeHeight); } else { $embedScript .= self::IFRAME_MARKETING_EMBED; $iframeString = sprintf('<div class="_rc_miframe" data-url="%s"></div>', $iframeUrl); } $jsString = sprintf('<script type="text/javascript" src="%s"></script>', $embedScript); return $iframeString . $jsString; }
public static function getAddonOptions($store = null) { $ret = array(); $ret['parent_private_key'] = self::getParentPrivateKey(); $ret['private_key'] = self::getPrivateKeys(); $ret['api_key'] = self::getApiKeys(); $ret['export_status'] = self::getExportStatuses(); $ret['last_request'] = self::formatDate(self::getLastRequest(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); $ret['last_resync'] = self::formatDate(self::getLastResync(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); $ret['addon_status'] = self::getStatusModule() == 'Y' ? 'enabled' : 'disabled'; $ret['addon_version'] = (string) Mage::getConfig()->getModuleConfig("Simtech_Searchanise")->version; $versionInfo = Mage::getVersionInfo(); $coreEdition = 'Community'; // [v1.7] [v1.8] [v1.9] if (method_exists('Mage', 'getEdition')) { $coreEdition = Mage::getEdition(); // [/v1.7] [/v1.8] [/v1.9] // [v1.5] [v1.6] } elseif (isset($versionInfo['minor']) && $versionInfo['minor'] > 6) { $coreEdition = 'Enterprise'; } // [/v1.5] [/v1.6] $ret['core_edition'] = $coreEdition; $ret['core_version'] = Mage::getVersion(); $ret['core_version_info'] = $versionInfo; return $ret; }
public function isNewMagento() { $mage = new Mage(); if (!is_callable(array($mage, 'getEdition'))) { $edition = 'Community'; } else { $edition = Mage::getEdition(); } unset($mage); $version = Mage::getVersionInfo(); $m1 = $version['major']; $m2 = $version['minor']; $v = $m1 * 1000 + $m2 * 10; if ($edition == 'Enterprise') { if ($v >= 1140) { // 1.14 return true; } } else { if ($v >= 1090) { // 1.9 return true; } } return false; }
public function isMagetoEnterprise() { $isEnterprise = false; $i = Mage::getVersionInfo(); if ($i['major'] == 1) { if (method_exists('Mage', 'getEdition')) { if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) { $isEnterprise = true; } } elseif ($i['minor'] > 7) { $isEnterprise = true; } } return $isEnterprise; }