5

I understand how to add blocks via layout xml. But i have a situation where i want to add a few of these blocks on only enterprise edition. On other edition it should work as if that block has not even been added in the xml.

I know that there is an attribute called ifconfig but is it reliable for determining the enterprise edition? If so, what could be the configuration node i could check?

Another way for achieving the above, i was thinking of listening to an appropriate event & add a new layout handle (or maybe a new layout xml file?) for enterprise editions & add my new blocks in that. Am i doing it right or is there any better/easier way?

Also i would prefer if i do not have to do it via php code as that code will get very lengthy with the number of blocks & also because all the blocks that are added on community edition are being added via xml

  • Did you try ifconfig="modules/Enterprise_Enterprise/active"? – Dmytro Zavalkin Aug 15 '13 at 7:56
  • Yes, but not working. I think it only supports fields from under system config – Mridul Aggarwal Aug 15 '13 at 17:41
  • What about ifconfig="system/media_storage_configuration/allowed_resources/enterprise_folder"? I know, it doesn't look clean but better than with php code. – Dmytro Zavalkin Aug 15 '13 at 19:07
  • Perfect. Can you please put that as an answer? One thing i would like to note though is that default magento doesn't support ifconfig on block tag, it only accepts on action tag. So if your block has type as one of the Enterprise classes, you should still go for php code – Mridul Aggarwal Aug 16 '13 at 22:20
  • For my solution though, i ended up dynamically adding a new enterprise-only xml file. – Mridul Aggarwal Aug 16 '13 at 22:32
1

What about ifconfig="system/media_storage_configuration/allowed_resources/enterprise_folde‌​r"? I know, it doesn't look clean but better than with php code.

P.S. To make ifconfig attribute work on block tag you should install Aoe_LayoutConditions module.

5

Don't use layout XML

Rather than using layout XML, perhaps add the block in the parent block programmatically from within your conroller, using Mage::getEdition(), which has been available since 1.12 EE.

It would look something like this:

if(Mage::getEdition()=='Enterprise'){


    $block = $this->getLayout()
        ->createBlock('core/template')
        ->setTemplate('myfolder/myfile.phtml');

    $this->getLayout()->getBlock('content')->append($block);

}

Possible values for Magento's Edition constants are:

const EDITION_COMMUNITY    = 'Community';
const EDITION_ENTERPRISE   = 'Enterprise';
const EDITION_PROFESSIONAL = 'Professional';
const EDITION_GO           = 'Go';

I don't care, I want Layout XML

You can use ifconfig, but your installer will have to create a config entry for the edition in a startup script. That will have to return a 'true' value (1); let's call that config node system/magento/enterprise_edition:

<block ifconfig="system/magento/enterprise_edition" type="enterprise_customerbalance/checkout_onepage_payment_additional" .../>

I need support for < 1.12

As stated, Mage::getEdition() won't work for < 1.12; The layout XML example would work, but you'd have to sniff which version for your installer. SweetToothRewards does this by checking the presence of a module:

/**
 * True if the version of Magento currently being run is Enterprise Edition
 */
public function isMageEnterprise() {
    return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
}


public function isMageProfessional() {
    return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
}


public function isMageCommunity() {
    return !$this->isMageEnterprise() && !$this->isMageProfessional();
}

Source: https://gist.github.com/jayelkaake

  • +1 for the useful information. However, i prefer doing it via xml only. The reason is that all the other blocks(that are added irrespective of edition) are all added via xml. This makes things more consistent. – Mridul Aggarwal Aug 14 '13 at 11:25
  • See my most recent update. – philwinkle Aug 14 '13 at 11:38
0

instead of determining versions determine the feature. If you add this with layout file then place the layout file that has this rule to app/design/frontend/enterprise/default/layout folder and it will be included only for enterprise installations.

  • but how to determine the feature? In one of the block, i have to show it if store credit feature is available, i have <block type="enterprise_customerbalance/checkout_onepage_payment_additional" .../>. However this throws an exception on community edition. – Mridul Aggarwal Aug 14 '13 at 10:41
  • add the block via xml and inside this block check if store_credit module is present and if it is enabled – Anton S Aug 14 '13 at 11:28
  • I don't really understand what you mean here, can you give me an example? Take the xml mentioned in previous comment for an example. – Mridul Aggarwal Aug 14 '13 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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