Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6839901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:46:31+00:00 2026-05-26T23:46:31+00:00

I have a custom module that displays data on my product pages. My module

  • 0

I have a custom module that displays data on my product pages. My module needs to get the current product id. I tried using:

Mage::registry('current_product');

This works on the first load but when I refresh, current_product no longer has data with full page caching on.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:46:32+00:00Added an answer on May 26, 2026 at 11:46 pm

    The catalog product action controller isn’t dispatched, when the full page cache handles the request (which makes sense to keep things fast).
    So, the registry variables are never set.
    I assume you are generating the block dynamically on the otherwise fully cached page.
    My recommendation is to try to avoid expensive loads, since that would undermine the speed improvements by the full page cache. You really want to cache the block if at all possible, even if it’s a separate cache entry for each customer and each product.

    That said, here is how to do that:

    In the container, implement the _getIdentifier() method:

    protected function _getIdentifier()
    {
        return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
    }
    

    Also expand the _getCacheId() method to include the return value of the method _getIdentifier() and a new placeholder attribute: product_id

    protected function _getCacheId()
    {
        return 'HOMEPAGE_PRODUCTS' . md5($this->_placeholder->getAttribute('cache_id') . ',' . $this->_placeholder->getAttribute('product_id')) . '_' . $this->_getIdentifier();
    }
    

    Next, in the block class, extend the method getCacheKeyInfo(). All entries in the cache_key_info array with a string index are set on the placeholder as attributes. That is how we can pass the product id to the placeholder.

    public function getCacheKeyInfo()
    {
        $info = parent::getCacheKeyInfo();
        if (Mage::registry('current_product'))
        {
            $info['product_id'] = Mage::registry('current_product')->getId();
        }
        return $info;
    }
    

    Then enable the method _saveCache() by not overriding it in your container class and returning false.
    So now, because the container returns a valid id from _getCacheId(), and _saveCache() is inherited from the parent class, the the block can be cached, and applied to the content in an efficient manner in Enterprise_PageCache_Model_Container_Abstract::applyWithoutApp().

    You can set the lifetime of the cache entry by having your container extend from Enterprise_PageCache_Model_Container_Customer instead of Enterprise_PageCache_Model_Container_Abstract.

    If you still need to pass the product_id to the block (even though it’s cached now), you can do so in the _renderBlock() method of your container:

    protected function _renderBlock()
    {
        $blockClass = $this->_placeholder->getAttribute('block');
        $template = $this->_placeholder->getAttribute('template');
    
        $block = new $blockClass;
        $block->setTemplate($template)
            ->setProductId($this->_placeholder->getAttribute('product_id'));
        return $block->toHtml();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom module that exports data to our fulfillment system when the
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I have a custom data structure that I want to display in a PyQt
I made a custom module that sell used product along with original product and
I have a dot net nuke site that I have written a custom module
I have created a custom module that creates a custom Database table. I have
Lets Suppose that I have made a custom authentication module that inherits IHttpModule class.
I have created a custom module which displays a tab and a section in
I have been editing a module in Joomla that lets me display custom HTML
I have an application that makes used of a custom login module of JBoss.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.