Skip to content

Instantly share code, notes, and snippets.

@daniel-ifrim
daniel-ifrim / README.md
Created January 22, 2019 19:59
Magento 1 extend filter, add 2 additional if statements and support in if statements conditions like ==, !=, >= and other

Note:

  • This class extends the original Magento 1 class Varien_Filter_Template.
  • If you use it in newer Magento 1 versions please upgrade your code: compare filter method code from original class and change MyLibNamsepace_Filter_Template accordingly.
  • To make the above code work with emails you need to rewrite the core class Mage_Core_Model_Email_Template_Filter to extend the bove class instead of extending default class Varien_Filter_Template

Usage:

{{outer_if myVar!=="ipsum"}} {{if customer.getGroupId()==2}} Public text

@daniel-ifrim
daniel-ifrim / Filter.php
Last active April 10, 2022 15:37
Extend Magento 2 templates. Add operators equal, greater than, lower than and other. Add 2 more if.
<?php
// app/code/MyNamespace/MyModule/Model/Template/Filter.php
namespace MyModule\MyNamespace\Model\Template;
/**
* Class Filter
*
* @note Contains redundat code with \LS\EmailExtend\Framework\Filter\Template
* @see \MyModule\MyNamespace\Framework\Filter\Template
* @see \Magento\Email\Model\Template\Filter
@daniel-ifrim
daniel-ifrim / README.md
Created July 27, 2018 16:15 — forked from timneutkens/README.md
Magento2 | Execute data-mage-init and x-magento-init in dynamic content (ajax request)

Execute data-mage-init and x-magento-init in dynamic content (ajax response)

Trigger .trigger('contentUpdated') on the element where dynamic content is injected.

$.ajax({
    url: 'https://www.example.com',
    method: 'POST',
    data: {
 id: '1'