nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
520 stars 253 forks source link

GetFullActionName return turpentine_esi_getBlock #1350

Open jeremydevos opened 7 years ago

jeremydevos commented 7 years ago

Hello,

I have a problem when calling getFullActionName on code part in ESI block. Turpentine return turpentine_esi_getBlock instead catalog_product_view for exemple.

Any ideas?

Ty Jeremy

miguelbalparda commented 7 years ago

Can you add some more info and context please? Maybe some code will help.

miguelbalparda commented 7 years ago

Also, have you checked https://github.com/nexcess/magento-turpentine/issues/1192?

jeremydevos commented 7 years ago

Hello,

Yes I checked the ticket #1192 but no solution.

Here is more information :

Module XML :

<default>
        <reference name="before_body_end">
            <block type="googletagmanager/tag" name="googletagmanager_tag" template="googletagmanager/datalayer.phtml"/>
        </reference>
</default>

Local XML : (local.xml - default node)

<reference name="googletagmanager_tag">
            <action method="setEsiOptions">
                <params>
                    <method>esi</method>
                    <access>private</access>
                    <scope>page</scope>
                    <ttl>0</ttl>
                </params>
            </action>
</reference>

Block Tag.php :

class Xxxxx_Googletagmanager_Block_Tag extends Mage_Core_Block_Template
{
    protected function getGtmData()
    {
        $actionName = $this->getAction()->getFullActionName();
        switch ($actionName) {
            case "cms_index_index" : 
                ...
                break;
            case "catalog_category_view" : 
                ...
                break;
            case "catalog_product_view" :
                ...
                break;
        }
    }
}

In front HTML Code with debug :

<!-- ESI START [xxxx_googletagmanager_tag] -->
<!-- ESI URL: http://xxx.xxxxxxxxxx.xxx/turpentine/esi/getBlock/method/esi/access/private/ttl/0/hmac/9705bd722f50c384fe57739933adccb28e078f23c6c24cd6c295e324c61d4b35/data/PVYTJlh7UCY2y_27LJdSnSaSdmsJenWQ6fzyES0E58cBFiMRnLyp5XjbjXAfB77pSuEV-F41JSowV-7wl9siZWENPEHdIEUpwPSs3RMI8oxC76PK-iG-bWpUoitMjL8XqMIcpCxFZIBqvEDzSaC9a3aIFA2naxyK_tIjZN8kcV5XvGI3XdJY6E96wuj4XoQqC9qNisu0LrGSgkrlRQS8uCOKES4XIJnk0_AiwXPEt_MLdcIc3d7bk9pUyveRAzcPjWp9H6QSeT79oFRNM06VMwydbkQTYnN4WxaLJhncyFj-Besce7Lcf6EkxXWl1oA-1aD3HA8tnJ0UmXYDLVQb0s5JEORElYIHFXNebe1BZ2ip_fGtRBesl_7ts9yJDX7FT4Q5STTFfndplPoVz3ZfZA==/r64/aHR0cDovL3JlY2V0dGUuY2hhdXNwb3J0LmJpei9sL2NoYXVzc3VyZXMvaG9tbWUuaHRtbA,,/ -->

turpentine_esi_getBlock (echo debug getFullActionName)
<!-- Google Tag Manager BEGIN -->
<!-- Google Tag Manager Code -->
<!-- Google Tag Manager END -->
<!-- ESI END [xxxxx_googletagmanager_tag] -->

The problem is that on a product listing, a listing produces the getFullActionName returns turpentine_esi_getBlock instead of catalog_product_view / catalog_product_list

For your information, we use a Controller_Router (deviation) custom for rewrite url with for example xxx.xxxxx.xxx/p/............html for a product and xxx.xxxxx.xxx/l/...........html for a listing Xml :

<config>
    <frontend>
        <routers>
            <deviation>
                <use>standard</use>
                <args>
                    <module>Xxxxx_Deviation</module>
                    <frontName>deviation</frontName>
                </args>
            </deviation>
        </routers>
    </frontend>
</config>

Class Controller_Router :

class Xxxxxx_Deviation_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract
{
public function initControllerRouters($observer)
    {
        /* @var $front Mage_Core_Controller_Varien_Front */
        $front = $observer->getEvent()->getFront();
        $front->addRouter('deviation', $this);
    }

Do not hesitate if you need more information

miguelbalparda commented 7 years ago

Can you try using <method>ajax</method> and report back?

jeremydevos commented 7 years ago

Same problem with ajax

actionName = this->getAction()->getFullActionName(); actionName = turpentine_esi_getBlock

miguelbalparda commented 7 years ago

That was a long shot. Basically this is not a bug, it's how this module is supposed to work. Most of the times we suggest to try to grab this value with JS, which might be a solution for you. If I understand this correctly you are trying to inject different tags in different pages right?

jeremydevos commented 7 years ago

Yes, This is the google tag manager datalayer, so the values change for each page, each customer.

miguelbalparda commented 7 years ago

You could try to use a custom registry_key or a dummy_block, here you can find the documentation for those. For example, you can use current_product and current_category registry keys to check for a product or category page.