Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy issue for product_list_toolbar + ESI Processing not enabled errors #1097

Closed
pascaladriaansen opened this issue Feb 10, 2016 · 11 comments

Comments

@pascaladriaansen
Copy link

Hi!

I'm having some issues with setting up ESI cache policies resulting in ESI Processing not enabled errors.

1. Product list toolbar

Because we have different prices / catalog rules for different customer groups, I have set the following policy for the product_list block:

<catalog_category_layered>
        <reference name="product_list">
            <action method="setEsiOptions">
                <params>
                    <access>customer_group</access>
                    <scope>page</scope>
                    <registry_keys>
                        <current_category/>
                    </registry_keys>
                </params>
            </action>
        </reference>
</catalog_category_layered>

This successfully shows the correct prices to each customer group. Unfortunately, this policy renders the product_list_toolbar unusable. Any action like sorting or changing the grid/list mode links to an incorrect URL. For example, the grid mode button links to /?mode=grid (note that the current category path is not even in this URL). We're using Manadev Layered Navigation, so it should link to something like /my-current-category/mode/grid.

After setting an ESI policy for the product_list_toolbar block that sets access to private and a ttl of 0 so it won't be cached, a ESI Processing is not enabled message is shown.

I found out that a PHP fatal error occurs when the product_list_toolbar block tries to render:
PHP message: PHP Fatal error: Call to a member function getSize() on a non-object in /data/web/package/app/design/frontend/mytheme/mypackage/template/catalog/product/list/toolbar.phtml on line 34
Line 34 contains this: $this->getCollection()->getSize(). So, for some reason, $this->getCollection() doesn't return a valid collection object. I have tried to add some registry keys to the product_list_toolbar block's ESI policy, because it seems like it needs the current_category, current_product and current_layer registry keys to know how the URLs should be generated:

<reference name="product_list_toolbar">
            <action method="setEsiOptions">
                <params>
                    <access>private</access>
                    <ttl>0</ttl>
                    <scope>page</scope>
                    <registry_keys>
                        <current_category/>
                        <current_product/>
                        <current_layer/>
                    </registry_keys>
                </params>
            </action>
        </reference>

Unfortunately, this doesn't change a thing. I have tried everything I could think of but nothing worked. Do you have any idea how I should fix this?

2. Can't find block(s) showing ESI Processing not enabled message(s)

Another problem I am facing is that on the same page, just above the product_list_toolbar block, is another ESI Processing not enabled message. I have tried to comment out any $this->getChildHtml() on that page to find out which block is rendering this error message, but no matter which blocks I comment out, the message still shows.

How can I determine which block is causing this issue? I have already tried Block logging and enabling Debug Info, but I can't find anything related to the ESI Processing not enabled message.

If it helps, this is what the source code looks like:
Screenshot
I noticed the <!-- ESI START [product_list] --> seems to be missing.

Thanks! :)

@aricwatson
Copy link
Contributor

@pascaladriaansen have you tried using the ajax method for the product_list block?

For problem #2 - can you tell which block would normally be rendered here by looking at the HTML generated in that spot when bypassing varnish? I suspect the problems you're having with product_list might be causing the ESI issues.

Also - for both of these issues, have you examined the logs for any hints as to what might be going wrong?

@pascaladriaansen
Copy link
Author

@aricwatson I have tried the ajax method for the product_list block. This resolves my second issue, but the product_list_toolbar block still doesn't have a collection and I think that's why the links for sorting etc. are still not generated correctly. I have done some digging in the product_list's block PHP files and found that the collection on the product_list_toolbar is set in the _beforeToHtml() method:

File app/code/core/Mage/Catalog/Block/Product/List.php line 133 - 169:

/**
     * Need use as _prepareLayout - but problem in declaring collection from
     * another block (was problem with search result)
     */
    protected function _beforeToHtml()
    {
        $toolbar = $this->getToolbarBlock();

        // called prepare sortable parameters
        $collection = $this->_getProductCollection();

        [...]

        // set collection to toolbar and apply sort
        $toolbar->setCollection($collection);

        [...]

And this is the _getProductCollection method:

/**
     * Retrieve loaded category collection
     *
     * @return Mage_Eav_Model_Entity_Collection_Abstract
     */
    protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $layer = $this->getLayer();

            [...]

            $this->_productCollection = $layer->getProductCollection();

            $this->prepareSortableFieldsByCategory($layer->getCurrentCategory());

            if ($origCategory) {
                $layer->setCurrentCategory($origCategory);
            }
        }

        return $this->_productCollection;
    }

It seems that it needs the current_layer registry key (I logged the $layer variable to my system.log and it ended up being empty) to get the product collection from. So what I tried to do was add the current_layer registry key to my ESI settings in the layout.xml:

<catalog_category_layered>
        <reference name="product_list">
            <action method="setEsiOptions">
                <params>
                    <access>customer_group</access>
                    <scope>page</scope>
                    <method>ajax</method>
                    <registry_keys>
                        <current_category/>
                        <current_layer/>
                    </registry_keys>
                </params>
            </action>
        </reference>
</catalog_category_layered>

Unfortunately, this results in the following exception:
a:5:{i:0;s:64:"Serialization of 'Mage_Core_Model_Config_Element' is not allowed";i:1;s:4733:"#0 /data/web/plugins/Nexcessnet_Turpentine/app/code/community/Nexcessnet/Turpentine/Helper/Data.php(165): serialize(Array)

I have no idea where to look for a solution regarding this exception. Any ideas?

edit: Ok, forget the above stuff about the current_layer registry key... When simply setting a ESI policy for just the product_list block, I found out that the toolbar gets a valid product collection. The links are still not generated correctly, but it seems this has something to do with the Manadev Layered Navigation plugin overriding some methods in the Mage_Core_Model_Url class. I still haven't found out what exactly is causing the url's to be generated incorrectly, but I think I'm on the right track.

@aricwatson
Copy link
Contributor

The links are still not generated correctly, but it seems this has something to do with the Manadev Layered Navigation plugin overriding some methods in the Mage_Core_Model_Url class.

That sounds likely - what are the methods that are being overridden?

@dartsuresh
Copy link

Hi,
Am having some issue with my purchased theme and varnish and turpentine.

After enable turpentine with varnish header and footer are missing with some error. Please advise me.
error

We used Sm market theme.
My website URL
http://magvarn.demodooms.com/

PLease advise me.

@miguelbalparda
Copy link
Contributor

@dartsuresh Turpentine is not a plug and play module. You might need to do some changes to your theme to make the module work. Have you checked the wiki?

@dartsuresh
Copy link

Sorry for this, Am new in magento and varnish. Can yyou please provide the Wiki url where can i change the theme work with?

@miguelbalparda
Copy link
Contributor

@dartsuresh
Copy link

Yes I did the same steps here. How to know what are the changes we need to do in theme.?
Here my varnish log
#109

Pleae advise.

@miguelbalparda
Copy link
Contributor

@dartsuresh that will depend on your theme's structure.

@magefan
Copy link

magefan commented Mar 21, 2016

I have the same issue.
In my case adding the code

$this->setAlias(
Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
ltrim($this->getOriginalPathInfo(), '/')
);

right before return true;
in Nexcessnet_Turpentine_Model_Dummy_Request::_defaultRouterMatch
fix the issue with pagination but i steel have a problem with filtering.

@aricwatson
Copy link
Contributor

Closing this for now. @magefan if you're still having problems with filtering, feel free to open a new issue with specifics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants