Blog Post

Using Pimcore Views in Magento

After a bit of a hiatus due to work pressures I am back busy working on integrating Magento and Pimcore.  Over the next few months I hope to launch a new product which is a full integration between Pimcore and Magento using the best of both systems.

As a first step towards this I decided that I needed to be able to use a single system for certain areas of the site, such as footer, header etc as well as being able to include Pimcore views directly in Magento.  This post is the beginning of that work.  While the full integration will be a commercial offering I thought that many people might find the ability to use Pimcore views in Magento useful so have decided to release a small Magento extension to the community.  The extension can be downloaded from

I'm not going to go into the extension code too much as it should be pretty self explanatory, rather the rest of the post will be showing how to implement this in Magento with a few modifications to your Pimcore view scripts.

Once you have installed the Magento extension, the first thing yoou need to do is tell it the path to your Pimcore installation.  In your Magento admin backend, navigate to System>Configuration>Magepim>Pimcore Integration and enter the full server path to your Pimcore instalation, e.g. /var/www/pimcore (please note that Magento and Pimcore do need to be on the same server and have access to each other for this at the moment).  Once this is set you are ready to start using Pimcore views in Magento.

A good example of using Pimcore views in Magento can be found over at Here, I include a few areas in my Magento store, the most obvious one being the right hand panel that shows up the latest blog articles.  In my Magento outer template (in this case 2columns-right.phtml) I insert a call to the Pimcore view helper telling it to use the same Pimcore view template as I use on the main Pimcore site as below.

<?php echo  Mage::helper('pimcore/view')->pimcoreTemplate("/website/views/scripts/blog/sidebar.php") ?>

In this call you have to use the full path to the Pimcore view template rather than the relative path used as standard in Pimcore.  This is something I am working on to bring the two systems into alignment so expect this to change.

The next thing to do is make some modifications to your Pimcore site.  Where as in Magento you set the Base URL for your store, in Pimcore this does not have to be set.  However, for Magento to use things like images and links it needs to know the base domain of the Pimcore site.  In your Pimcore backend, go to settings>system>website and set the Main Domain setting to be the domain name (and path if needed) of your Pimcore install.  In my case, this is just (no http:// needed).  Once this has been done you now need to make some modifications to your Pimcore view templates.  The first of which is to get the domain name of your Pimcore site.  In the relevant template add the following.

        $useCustomLink = false;
        $conf = Zend_Registry::get("pimcore_config_system");
        $baseUrl = 'http://' . $conf->general->domain;
        if(!$this->document) {
            $document = Document::getByPath('/');?>
            <?php $this->document = $document;
               $useCustomLink = true;

This sets up the template for when it's being called from Magento and we only need to use this on calls from Magento hence the $useCustomLInk which we will come to next.

Whenever you have a link being pulled from Pimcore (for example links to blog posts direct in Pimcore) you need to form the link slightly differently to how you usually do in Pimcore.

             * This is used when Magento is rendering the link
                 $detailLink = $baseUrl.str_replace('-','+',$article->getFullPath());
            $detailLink .='_b'.$article->getId();
            }else {
                 * Normal Pimcore link rendering
                $detailLink = $this->url(
                        "id"     => $article->getId(),
                        "text"   => $article->getTitle(),
                        "prefix" => $this->document->getProperty("blog")->getFullPath()

For images, just prepend the normal Pimcore image URL with the baseUrl set earlier

<img class="media-object" src="<?= $baseUrl?><?= $article->getPosterImage("blog-thumbnail") ?>" alt="Blog Message">

That's it!  You should now have Pimcore view templates being rendered in your Magento site.

If you have any feature requests for this or want to contribute then please get in touch and I'll see what I can do.

comments powered by Disqus