8

Is there a clean way to make a difference code wise between EE and CE?
The problem.
I'm updating an extension so it will work nicely on ce-1.9.
The extension is not for EE, but it seams to work on that also.
For the update I need to create an upgrade script that should be executed only if installed on CE-1.9 (or EE 1.14).
I cannot simply check

version_compare(Mage::getVersion, '1.9', '>=');

because this will be triggered in EE 1.9+ and I don't want that.

Right now I'm using this:

$isEE = Mage::helper('core')->isModuleEnabled('Enterprise_Enterprise');

but it seams kind of ugly.

Any other ways to check?

2
  • This is how I've done it previously, although I seem to remember Professional included some Enterprise elements - but if you're checking version too, you're probably good to go there. This was the reference I used at the time: gist.github.com/jayelkaake/1541793 Jul 28, 2014 at 9:04
  • @DouglasRadburn I don't care about professional anymore because it's discontinued. Glad to know someone does it the same. Please put your comment as an answer, and If nothing else comes up in the next 2 days I'l accept it.
    – Marius
    Jul 28, 2014 at 9:07

2 Answers 2

15

Since CE 1.7 you have Mage::getEdition() that gives this information:

/**
 * Magento edition constants
 */
const EDITION_COMMUNITY    = 'Community';
const EDITION_ENTERPRISE   = 'Enterprise';
const EDITION_PROFESSIONAL = 'Professional';
const EDITION_GO           = 'Go';

/**
 * Current Magento edition.
 *
 * @var string
 * @static
 */
static private $_currentEdition = self::EDITION_COMMUNITY;



/**
 * Get current Magento edition
 *
 * @static
 * @return string
 */
public static function getEdition()
{
   return self::$_currentEdition;
}
3
  • 1
    Thanks. I was looking for that. That's the second time today my search skills fail. "Today is not a good day for science".
    – Marius
    Jul 28, 2014 at 10:40
  • So you nee to check if the method exists first and then call it. If you care about CE 1.6
    – Amasty
    Jul 28, 2014 at 12:49
  • @Amasty. Yep. that's true. But I don't offer support for my extension on versions less than 1.7 so this should be ok.
    – Marius
    Jul 28, 2014 at 14:10
0

One other possible way is to navigate to root folder of magento 1 installation and run the following command in CLI.

php -r "require 'app/Mage.php'; echo Mage::getEdition(); "

Alternativelly if you want to get also the version

php -r "require 'app/Mage.php'; echo Mage::getEdition(); echo Mage::getVersion();"

works just fine.

1
  • maybe it works, but this is not what I asked.
    – Marius
    Sep 6, 2019 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.