Instead of just
including a block
into an email template, Magento makes it possible to load a hole tree of blocks or just in other words a layout.
Here a small post about the the
layout directive in Magento 2 email templates with source code examples
In the past I have written a few posts about email template directives for Magento 2.
I like to use Prism as syntax highlighter for my blog. So I have created a small grammer for Magento templates that are used for emails and for the CMS system.
Simon Sprankel contacted me a few days ago. He is using Lesti_FPC for a customer and he had a block in a few CMS pages. This block has to be dynamic or lazy. I have answered this tricky question a few times via email, but together we have found a good solution that I would like to present in this post.
I would like to explain the
inlinecss directives and the variable
template_styles of Magento 2 email templates in this post.
There are two logical directives that can be used in Magento 2 email templates. The
depend and the
if directives. I will explain both in this post.
The title is maybe a little bit confusing, better would be maybe child template directives. This post
explains how to include a child template in a Magento email template. Pretty popular examples are
It can be quite comfortable to use configuration values in Magento 2 email templates. Let us assume we change our store phone number in the configurations and it changes also in templates where we use sentences like: You can call us any time at .... I will show pretty fast in this post how to use the restricted list of configs in email templates and will explain ways to add your own configuration paths.
Magento 2 email templates are supposed to be translated sentence by sentence. This post shows how to use the translator directive.
This post tries to explain every possible way to use blocks in Magento 2 email templates.
I had the pleasure to give a talk about Magento 2 content under version control at the Meet Magento NL 2016.
Magento2 has reduced the use of events. I guess the Magento plug-ins are more powerful. Today I would like to show, how to create a list of all dispatched events after visiting the product page for example. I have written a similar post a few years ago for older Magento versions.
Lesti_Fpc is internal full page cache for Magento. This Cache needs no varnish or any other extenal software and works with events. It is an internal cache and so it replaces dynamic blocks before sending response to customer. Here is little post that explains the workflow of Lesti_Fpc.
When developing with Magento2 you have maybe come to the question were is my logger for example. This was the way in Magento before.
Mage::log('Some log message', null, 'file.log');
Maybe you have already found the logger here for example in the class Magento\Backup\Controller\Adminhtml\Index\Rollback.
Today I don't want to show you the logger. More interesting for me are the shared instances inside of the Objectmanager that you can use with the fucntion get.
If you have started developing a Magento2 shop with Composer you should have noticed that you will need some authentication keys. Alan Kent is explaining in his post Magento 2 and Composer Authentication why Magento thinks this is necessary. It doesn't make much sense to me why it is necessary also to store the open source extensions and modules in a protected repository, but I guess Magento is a control freak.
This protection is really a problem for maintaining open source extensions with Composer in a public continous integration. Today I would like to show how to use Travis CI for open source extensions with the password protected repository repo.magento.com from Magento2.
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
The problem was really homemade. My setup script tries to install Magento on every start of the container. But that leads me to the point to take a small look at the maintenance mode of Magento2.
I had the honor to give a talk about Recommender Systems at the Meet Magento NL 2015. It was an exciting event and I have met many interesting people.
From the 7th to the 8th March 2015 was the Magento Unconference 2015 #mageuc15. Unfortunately I have missed the pre-party at Friday, but I heard it was quite funny. I have been arrived at Saturday morning. Every participant had the opportunity to suggest a topic that he is interested in. It was a cool mix, for example Avoiding Burnout, Magento Search or Module testing. Sometimes it was a presentation, sometimes a discussion or a mix of both. It was a real community event.
Since two years I wasn't on any magento confernce. That's mostly because I'm a student and I haven't enough money for big conferences. So today I would like to promote the Mage Unconference 2015 and this post is my contribution. The conference will happen at 7th and 8th March 2015 in Berlin. I have my ticket and it would be pretty cool to meet some people from the magento community, that I only know from there github avatars.
Lesti_Fpc has changed in the last month. Some of the changes are part of the code quality. Today I would like to present the tools, that I use to raise the quality of my Magento extension.
In Lesti_Fpc 1.3.2 I have added the possibility to edit the cacheTags and Parameters via an event. The idea of the Fpc was very clear and simple, but every day I get requests from developers with problems, that aren't that simple. For example oblomovx wanted to Disable Cleaning of Categories after product save. Maybe 98% of all Fpc users didn't need the possibilty to disable this functionality. Or riznmage wanted to Add AJAX parameter to make a differnce between requests that are made by ajax and normal requests. I can understand the need of such a thing, but on the other site I can't implement every crazy idea or I just think that it is wrong to make a ajax request on a action that isn't normally made for it. To let the Fpc simple, but also give those people the possiblity for there workflow I have made it like Magento. I have dispatched some events to work a little bit more advanced with the behavior of the Fpc.
Today I would like to make a small review about the book Magento Product Types: Developer's Guide from Oleg Ishenko. I know Oleg since 3 years. He was my Chief Technical Officer at a Magento shop in Berlin. This book is not an introduction to Magento. With this book you will get deeper into product types of Magento. You will get a introduction to the core product types in Magento XML configuration. Every really interesting type is included Configurable Product Type, Bundle Product Type, Grouped Product Type and Downloadable Product Type. The author will show you after the core product types, how to create an own custom product type. Every Type has his own chapter and at least one tutorial with sample code in a git repository. Oleg also explains mostly every kind of configuration that Magento uses to define types. You should take a look at this book, if you want to know more about the complexity of products in Magento. And mostly everything revolves around products in e-commerce.
I did start building Lesti_Fpc2. I always wanted a flexible and most compatible solution for Magento. That was never easy. So in Lesti_Fpc I did use the event controller_action_layout_generate_blocks_before as anchor. Just to explain, as anchor I mean the point were the Full Page Cache stops normal behavior of Magento and sends cached response. Normally you want to have this anchor as early as possible. My anchor was very flexible, but also not that fast as I expected.
The Welcome Message in Magento 1.7 is a problem for Lesti_Fpc. You can find the reason in app/design/frontend/base/default/template/page/html/header.phtml.
<!-- ... --> <p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p> <!-- ... -->
The welcome message is just a function of the header block. Lesti_Fpc needs the welcome message in a seperated block. In Magento 1.8 this is solved and the name of the block is welcome. In Magento 1.7 there is a semi-solution in core, we just have to give a little help.
I have released Lesti_Fpc 1.1.5. What is new in this version? I have add a new field in the configurations. Miss Uri Params, not a really creative and good name. The idea behind this parameters is: No request with these parameters will be cached. For example:
It's getting a little bit complicated. All Miss Uri Param will be seperated by comma and every parameter is sperated with an = from a regular expression. Every request with the parameter limit as an integer will miss the Fpc. I know it makes the configurations complexer, but I guess it will help somebody.
The current Magento2 version is 220.127.116.11-dev45 and I would like to build a simple HelloWorld! extension. I guess the current version isn't that different to Magento1 and maybe it doesn't make that much sense to write this right now, but I just want to show the little difference in this moment.
I just wanted to write my first Hello World extension in Magento2, but it wasn't that easy. The normal way in Magento is to create a <module>.xml in app/etc/modules. For example my extension should have the Name Lesti_HelloWorld, I would create app/etc/modules/Lesti_HelloWorld.xml with the following content:
<?xml version="1.0"?> <config> <modules> <Lesti_HelloWorld> <active>true</active> <codePool>community</codePool> <depends> <Mage_Core/> </depends> </Lesti_HelloWorld> </modules> </config>
I stared the repository of magento2 since 1 year, but I never did take a look at it. Today I wan't to change this. My current status is commit a15ecb31976feb4ecb62f85257ff6b606fbdbc00. Maybe in a few weeks all of my post isn't the latest. Let's install magento2.
Since version 1.1.1 of Lesti_Fpc I get more support requests for the layered navigation. I did change the behavior of key generating in Lesti_Fpc to get more hits in the cache. I added the new field Uri Params in the configurations and wrote a post about it. This post is all you need to get your layered navigation work, but I guess it would be better to explain it again an example.
Two weeks ago, I did get my first bad review on magento connect. The review was for the extension Lesti::Smtp. I can't say how frustrating it was for me. I guess I'm able to take criticism and I know it looks very childish to write a post about it, but I just want say my oppinion about it. Here can you see the review of digisiil.
Lesti_Fpc needs the name_in_layout of a block to make that block lazy or dynamic. Magento needs a unique identitfier for every block in the layout. That is the Name in Layout of a block. You can get this name with the following function.
$blockName = $block->getNameInLayout();
Or you can find the name in the layout.xml of your extensions. For example the app/design/frontend/base/default/layout/checkout.xml.
<!-- ... --> <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-"> <!-- ... -->
The searched attribute is name.
I have changed the keys in Lesti_Fpc 1.1.1. There was a problem with parameters in the Cache. Not a real problem, but the cache has produced too much keys. That means, more memory for the cache, but the real problem was, the cache had too much misses.
Events in magento are very cool. Mostly events make it possible to build very modular extensions for magento. In my first steps, I always searched for a full list of magento events. The problem with these lists were, they aren't complete and outdated. And you will never find dynamic events like this.
In Lesti_Fpc 1.1.0 I created a new type of dynamic blocks. I call them lazy blocks. First I will explain what dynamic blocks are and what the difference to lazy blocks is.
Many full page caches are in front of Magento. Often Magento doesn't see the request. That makes external caches very fast. You only have to define a process in front of magento and send your own request. But external caches have to reload dynamic content with ajax and aren't that flexible. Lesti_Fpc has an other workflow.