Вопрос

We have a "{{config path variable" like below and I am seeing the following:

This variable {{config path='web/unsecure/base_url'}} is visible in email templates and in newsletter templates

But not or sometimes in custom variables (HTML)

{{config path='web/unsecure/base_url'}}

With sometimes I mean sometimes. It looks like it has something to do with other variables that are or aren't found in the same template ... Please find some examples below


Question: has anyone experienced something similar before?


Some tests I conducted

TEST 1

Created an empty email template with the following 3 links, where TEST123 contains the same first 3 links:

{{config path='web/unsecure/base_url'}}

{{config path='snh/emailsettings/headerfnt'}}

{{store url''}}

________________________

{{customVar code=TEST123}}

The result is that var 1-2-3 do print, but 4-5-6 do not

TEST 2

Created an empty email template with the following 3 links, where TEST123 contains the same first 3 links:

    {{customVar code=TEST123}

________________________

{{config path='web/unsecure/base_url'}}

    {{config path='snh/emailsettings/headerfnt'}}

    {{store url''}}

The result is that var 1-2-3-4-5-6 do print


Conclusion so far My conclusion is that apparently there is something to do with the order of variables being found. customvars need to be found and processed BEFORE other variables are found. I am digging through Varien filter & Core Template to find some logic as to why

Это было полезно?

Решение 2

This seems to be known in Magento. Posted in bugs/features.

Другие советы

It's probably your database entries.

Take a look at core_config_data:

SELECT `value` FROM `core_config_data` WHERE `path` = 'snh/emailsettings/headerfnt';

If it does return something, then it'd be a scope problem then. Check if scope and scope_id checks out (global, website, store level?). Safest way to go is default and 0, respectively.

If it does not return anything, then you need to insert something for this. You obviously probably know now what to insert, right?

Unfortunately magento2 supports only specific list of configurations to use in email template as config path.

To use your custom config path in email template you need to override the core functionality.

Below article explained it very well.

https://gordonlesti.com/magento-2-email-template-config-directives/

You can find how Magento does it - vendor/magento/module-variable/etc/di.xml

It's allowed to add new configuration paths in your module di.xml and they will be supported by email templates

 <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Variable\Model\Source\Variables">
        <arguments>
            <argument name="configPaths" xsi:type="array">
                <item name="general/store_information" xsi:type="array">
                    <item name="general/store_information/emergency_phone" xsi:type="string">1</item>
                    <item name="general/store_information/line_address" xsi:type="string">1</item>
                </item>
            </argument>
        </arguments>
    </type>
</config>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top