Skip to content

Instantly share code, notes, and snippets.

@unirgy
Created December 31, 2011 07:02
Show Gist options
  • Save unirgy/1543186 to your computer and use it in GitHub Desktop.
Save unirgy/1543186 to your computer and use it in GitHub Desktop.
<?php
class Helper
{
public function isModuleActive($code)
{
$module = Mage::getConfig()->getNode("modules/$code");
$model = Mage::getConfig()->getNode("global/models/$code");
return $module && $module->is('active') || $model;
}
public function compareMageVer($ceVer, $eeVer=null, $op='>=')
{
$eeVer = is_null($eeVer) ? $ceVer : $eeVer;
return $this->isModuleActive('Enterprise_Enterprise')
? version_compare(Mage::getVersion(), $eeVer, $op)
: version_compare(Mage::getVersion(), $ceVer, $op);
}
protected $_hasMageFeature = array();
public function hasMageFeature($feature)
{
if (!isset($this->_hasMageFeature[$feature])) {
$flag = false;
switch ($feature) {
case 'order_item.base_cost':
$flag = $this->compareMageVer('1.4.0.1', '1.8.0', '>=');
break;
case 'sales_flat':
$flag = $this->compareMageVer('1.4.1.0', '1.8.0', '>=');
break;
case 'wysiwyg_allowed':
$flag = $this->compareMageVer('1.4.0');
break;
case 'stock_can_subtract_qty':
$flag = $this->compareMageVer('1.4.1.1', '1.9.0', '>=');
break;
case 'indexer_1.4':
case 'table.product_relation':
case 'table.eav_attribute_label':
case 'table.catalog_eav_attribute':
case 'attr.is_wysiwyg_enabled':
$flag = $this->compareMageVer('1.4', '1.6');
break;
case 'track_number':
$flag = $this->compareMageVer('1.6', '1.11');
break;
}
$this->_hasMageFeature[$feature] = $flag;
}
return $this->_hasMageFeature[$feature];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment