Holepunching of header in magento storeHow to hole-punch full page cache without custom moduleIssues in implementing Holepunching in Magento FPCAdd Customs column to Admin > sales >orderCache modules and observersClear Magento Enterprise FPC for specific productRemove Custom Block from CacheMagento block cache doesn't work in redisMagento 2 - Checkout session empty in payment methodMagento 1.9 Cache Custom Block DataHow to disable cache for perticular template file in magento 1.9?

What are rules for concealing thieves tools (or items in general)?

What is the tangent at a sharp point on a curve?

When should a starting writer get his own webpage?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Does Shadow Sorcerer's Eyes of the Dark work on all magical darkness or just his/hers?

Print a physical multiplication table

"Marked down as someone wanting to sell shares." What does that mean?

Don't understand why (5 | -2) > 0 is False where (5 or -2) > 0 is True

How to remove space in section title at KOMA-Script

Air travel with refrigerated insulin

Why doesn't the chatan sign the ketubah?

How can I query the supported timezones in Apex?

Hackerrank All Women's Codesprint 2019: Name the Product

Would storms on an ocean world harm the marine life?

When did hardware antialiasing start being available?

Can "few" be used as a subject? If so, what is the rule?

Help with identifying unique aircraft over NE Pennsylvania

How to read string as hex number in bash?

What is the difference between something being completely legal and being completely decriminalized?

Align centered, ragged right and ragged left in align environment

Difficulty understanding group delay concept

How to find the largest number(s) in a list of elements?

Asserting that Atheism and Theism are both faith based positions

What will the french man say?



Holepunching of header in magento store


How to hole-punch full page cache without custom moduleIssues in implementing Holepunching in Magento FPCAdd Customs column to Admin > sales >orderCache modules and observersClear Magento Enterprise FPC for specific productRemove Custom Block from CacheMagento block cache doesn't work in redisMagento 2 - Checkout session empty in payment methodMagento 1.9 Cache Custom Block DataHow to disable cache for perticular template file in magento 1.9?













10















I have implemented holepunching of header in magento, and even though I have got it working on a per customer basis, I need the ability to take this one level deeper by making it work on diff cart item counts too.



Here is my code.



 class AD_PageCache_Model_Container_Header extends Enterprise_PageCache_Model_Container_Abstract 

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


// public function getCacheKeyInfo()
// $info = parent::getCacheKeyInfo();
// die('boo');
// $info['cart_count'] = Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();

// return $info;
//

protected function _getCacheId()
//return 'CONTAINER_HEADER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_placeholder->getAttribute('cart_count') ) . '_' . $this->_getIdentifier();
return 'CONTAINER_HEADER_' . md5( $this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier() );


protected function _renderBlock()
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');

$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();





My understanding from what I have been reading from holepunching threads on Magento is that Mage app is not initialized when FPC cache is serving the request, so basically the method of adding a placeholder attribute can't work, since




Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();




won't work, right?



And even though how is that it should be, but it didn't seem to run at all, like I placed a die() call in there but nothing happened.



So what I am missing? And how can I retrieve the cart items count so that it can be used to build the cache ID?



Progress: I found




Enterprise_PageCache_Model_Cookie::COOKIE_CART




but this changes only once upon cart updation. After that it stays same. This is weird, this feels like the solution but its behavior says otherwise.



I couldn't find cart items count in session either. So the only way I currently see to do this would be to save the cart quantity in session whenever it updates and then use that in _getIdentifier().



I found that observers are inconsistent for cart. For addition, updation the events are dispatched but for removal, it doesn't. So I guess I can add my observer to price updation of the quote somehow, if that is consistent in having observers?



Also, I did read Full Page Cache invalidation on cart (quote) change but itt handles using




Enterprise_PageCache_Model_Cookie::COOKIE_CART




which doesn't work well in my case, although I think the problem lies inside it. What/How? I am not sure.




Also the current version of EE we have running doesn't even have
Advanced folder under Model/Container. I am using EE 1.10.1.1




Any suggestions?










share|improve this question
























  • Not sure, but I think that this question is more related to Stack Overflow, but not this site...

    – Sergei Guk
    Jan 22 '13 at 22:27






  • 2





    Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

    – Ralph Tice
    Jan 22 '13 at 22:40






  • 1





    Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

    – B00MER
    Jan 23 '13 at 19:59











  • @SergeiGuk Well it's heavily related to Magento

    – j0k
    Jan 25 '13 at 10:24











  • @RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

    – Nirav Sheth
    Jan 27 '13 at 16:38















10















I have implemented holepunching of header in magento, and even though I have got it working on a per customer basis, I need the ability to take this one level deeper by making it work on diff cart item counts too.



Here is my code.



 class AD_PageCache_Model_Container_Header extends Enterprise_PageCache_Model_Container_Abstract 

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


// public function getCacheKeyInfo()
// $info = parent::getCacheKeyInfo();
// die('boo');
// $info['cart_count'] = Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();

// return $info;
//

protected function _getCacheId()
//return 'CONTAINER_HEADER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_placeholder->getAttribute('cart_count') ) . '_' . $this->_getIdentifier();
return 'CONTAINER_HEADER_' . md5( $this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier() );


protected function _renderBlock()
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');

$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();





My understanding from what I have been reading from holepunching threads on Magento is that Mage app is not initialized when FPC cache is serving the request, so basically the method of adding a placeholder attribute can't work, since




Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();




won't work, right?



And even though how is that it should be, but it didn't seem to run at all, like I placed a die() call in there but nothing happened.



So what I am missing? And how can I retrieve the cart items count so that it can be used to build the cache ID?



Progress: I found




Enterprise_PageCache_Model_Cookie::COOKIE_CART




but this changes only once upon cart updation. After that it stays same. This is weird, this feels like the solution but its behavior says otherwise.



I couldn't find cart items count in session either. So the only way I currently see to do this would be to save the cart quantity in session whenever it updates and then use that in _getIdentifier().



I found that observers are inconsistent for cart. For addition, updation the events are dispatched but for removal, it doesn't. So I guess I can add my observer to price updation of the quote somehow, if that is consistent in having observers?



Also, I did read Full Page Cache invalidation on cart (quote) change but itt handles using




Enterprise_PageCache_Model_Cookie::COOKIE_CART




which doesn't work well in my case, although I think the problem lies inside it. What/How? I am not sure.




Also the current version of EE we have running doesn't even have
Advanced folder under Model/Container. I am using EE 1.10.1.1




Any suggestions?










share|improve this question
























  • Not sure, but I think that this question is more related to Stack Overflow, but not this site...

    – Sergei Guk
    Jan 22 '13 at 22:27






  • 2





    Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

    – Ralph Tice
    Jan 22 '13 at 22:40






  • 1





    Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

    – B00MER
    Jan 23 '13 at 19:59











  • @SergeiGuk Well it's heavily related to Magento

    – j0k
    Jan 25 '13 at 10:24











  • @RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

    – Nirav Sheth
    Jan 27 '13 at 16:38













10












10








10


3






I have implemented holepunching of header in magento, and even though I have got it working on a per customer basis, I need the ability to take this one level deeper by making it work on diff cart item counts too.



Here is my code.



 class AD_PageCache_Model_Container_Header extends Enterprise_PageCache_Model_Container_Abstract 

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


// public function getCacheKeyInfo()
// $info = parent::getCacheKeyInfo();
// die('boo');
// $info['cart_count'] = Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();

// return $info;
//

protected function _getCacheId()
//return 'CONTAINER_HEADER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_placeholder->getAttribute('cart_count') ) . '_' . $this->_getIdentifier();
return 'CONTAINER_HEADER_' . md5( $this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier() );


protected function _renderBlock()
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');

$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();





My understanding from what I have been reading from holepunching threads on Magento is that Mage app is not initialized when FPC cache is serving the request, so basically the method of adding a placeholder attribute can't work, since




Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();




won't work, right?



And even though how is that it should be, but it didn't seem to run at all, like I placed a die() call in there but nothing happened.



So what I am missing? And how can I retrieve the cart items count so that it can be used to build the cache ID?



Progress: I found




Enterprise_PageCache_Model_Cookie::COOKIE_CART




but this changes only once upon cart updation. After that it stays same. This is weird, this feels like the solution but its behavior says otherwise.



I couldn't find cart items count in session either. So the only way I currently see to do this would be to save the cart quantity in session whenever it updates and then use that in _getIdentifier().



I found that observers are inconsistent for cart. For addition, updation the events are dispatched but for removal, it doesn't. So I guess I can add my observer to price updation of the quote somehow, if that is consistent in having observers?



Also, I did read Full Page Cache invalidation on cart (quote) change but itt handles using




Enterprise_PageCache_Model_Cookie::COOKIE_CART




which doesn't work well in my case, although I think the problem lies inside it. What/How? I am not sure.




Also the current version of EE we have running doesn't even have
Advanced folder under Model/Container. I am using EE 1.10.1.1




Any suggestions?










share|improve this question
















I have implemented holepunching of header in magento, and even though I have got it working on a per customer basis, I need the ability to take this one level deeper by making it work on diff cart item counts too.



Here is my code.



 class AD_PageCache_Model_Container_Header extends Enterprise_PageCache_Model_Container_Abstract 

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


// public function getCacheKeyInfo()
// $info = parent::getCacheKeyInfo();
// die('boo');
// $info['cart_count'] = Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();

// return $info;
//

protected function _getCacheId()
//return 'CONTAINER_HEADER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_placeholder->getAttribute('cart_count') ) . '_' . $this->_getIdentifier();
return 'CONTAINER_HEADER_' . md5( $this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier() );


protected function _renderBlock()
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');

$block = new $blockClass;
$block->setTemplate($template);
return $block->toHtml();





My understanding from what I have been reading from holepunching threads on Magento is that Mage app is not initialized when FPC cache is serving the request, so basically the method of adding a placeholder attribute can't work, since




Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();




won't work, right?



And even though how is that it should be, but it didn't seem to run at all, like I placed a die() call in there but nothing happened.



So what I am missing? And how can I retrieve the cart items count so that it can be used to build the cache ID?



Progress: I found




Enterprise_PageCache_Model_Cookie::COOKIE_CART




but this changes only once upon cart updation. After that it stays same. This is weird, this feels like the solution but its behavior says otherwise.



I couldn't find cart items count in session either. So the only way I currently see to do this would be to save the cart quantity in session whenever it updates and then use that in _getIdentifier().



I found that observers are inconsistent for cart. For addition, updation the events are dispatched but for removal, it doesn't. So I guess I can add my observer to price updation of the quote somehow, if that is consistent in having observers?



Also, I did read Full Page Cache invalidation on cart (quote) change but itt handles using




Enterprise_PageCache_Model_Cookie::COOKIE_CART




which doesn't work well in my case, although I think the problem lies inside it. What/How? I am not sure.




Also the current version of EE we have running doesn't even have
Advanced folder under Model/Container. I am using EE 1.10.1.1




Any suggestions?







magento-1.9 cache full-page-cache holepunching






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 11 hours ago









Shoaib Munir

2,1101828




2,1101828










asked Jan 22 '13 at 22:11









Nirav ShethNirav Sheth

7114




7114












  • Not sure, but I think that this question is more related to Stack Overflow, but not this site...

    – Sergei Guk
    Jan 22 '13 at 22:27






  • 2





    Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

    – Ralph Tice
    Jan 22 '13 at 22:40






  • 1





    Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

    – B00MER
    Jan 23 '13 at 19:59











  • @SergeiGuk Well it's heavily related to Magento

    – j0k
    Jan 25 '13 at 10:24











  • @RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

    – Nirav Sheth
    Jan 27 '13 at 16:38

















  • Not sure, but I think that this question is more related to Stack Overflow, but not this site...

    – Sergei Guk
    Jan 22 '13 at 22:27






  • 2





    Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

    – Ralph Tice
    Jan 22 '13 at 22:40






  • 1





    Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

    – B00MER
    Jan 23 '13 at 19:59











  • @SergeiGuk Well it's heavily related to Magento

    – j0k
    Jan 25 '13 at 10:24











  • @RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

    – Nirav Sheth
    Jan 27 '13 at 16:38
















Not sure, but I think that this question is more related to Stack Overflow, but not this site...

– Sergei Guk
Jan 22 '13 at 22:27





Not sure, but I think that this question is more related to Stack Overflow, but not this site...

– Sergei Guk
Jan 22 '13 at 22:27




2




2





Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

– Ralph Tice
Jan 22 '13 at 22:40





Holepunching seems to be used here in a non traditional sense, can you explain the feature you're trying to implement without using jargon?

– Ralph Tice
Jan 22 '13 at 22:40




1




1





Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

– B00MER
Jan 23 '13 at 19:59





Why not append the customers cart id to _getIdentifier so the block is unique to customers cart, or even the number of items in their cart?

– B00MER
Jan 23 '13 at 19:59













@SergeiGuk Well it's heavily related to Magento

– j0k
Jan 25 '13 at 10:24





@SergeiGuk Well it's heavily related to Magento

– j0k
Jan 25 '13 at 10:24













@RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

– Nirav Sheth
Jan 27 '13 at 16:38





@RalphTice I'm trying to implement a cart value indicator in the header which shows the user how many items they have in their cart. Since that value is different per user, I don't want it to be cached.

– Nirav Sheth
Jan 27 '13 at 16:38










1 Answer
1






active

oldest

votes


















3














Using Enterprise_PageCache_Model_Cookie::COOKIE_CART is the right way to go, but you may need to do some changes.



Enterprise_PageCache_Model_Observer::registerQuoteChange is called on every quote save (item number change included) and it is also called in the context on Mage::app() so you can access all session data. Overwrite this observer and add more data in $this->_getCookie()->setObscure so the value changes whenever you need to.






share|improve this answer

























  • Any examples you might be willing to share on doing this?

    – Nirav Sheth
    Feb 4 '13 at 16:01










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f27%2fholepunching-of-header-in-magento-store%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Using Enterprise_PageCache_Model_Cookie::COOKIE_CART is the right way to go, but you may need to do some changes.



Enterprise_PageCache_Model_Observer::registerQuoteChange is called on every quote save (item number change included) and it is also called in the context on Mage::app() so you can access all session data. Overwrite this observer and add more data in $this->_getCookie()->setObscure so the value changes whenever you need to.






share|improve this answer

























  • Any examples you might be willing to share on doing this?

    – Nirav Sheth
    Feb 4 '13 at 16:01















3














Using Enterprise_PageCache_Model_Cookie::COOKIE_CART is the right way to go, but you may need to do some changes.



Enterprise_PageCache_Model_Observer::registerQuoteChange is called on every quote save (item number change included) and it is also called in the context on Mage::app() so you can access all session data. Overwrite this observer and add more data in $this->_getCookie()->setObscure so the value changes whenever you need to.






share|improve this answer

























  • Any examples you might be willing to share on doing this?

    – Nirav Sheth
    Feb 4 '13 at 16:01













3












3








3







Using Enterprise_PageCache_Model_Cookie::COOKIE_CART is the right way to go, but you may need to do some changes.



Enterprise_PageCache_Model_Observer::registerQuoteChange is called on every quote save (item number change included) and it is also called in the context on Mage::app() so you can access all session data. Overwrite this observer and add more data in $this->_getCookie()->setObscure so the value changes whenever you need to.






share|improve this answer















Using Enterprise_PageCache_Model_Cookie::COOKIE_CART is the right way to go, but you may need to do some changes.



Enterprise_PageCache_Model_Observer::registerQuoteChange is called on every quote save (item number change included) and it is also called in the context on Mage::app() so you can access all session data. Overwrite this observer and add more data in $this->_getCookie()->setObscure so the value changes whenever you need to.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 '16 at 15:03









Raphael at Digital Pianism

54.8k22119279




54.8k22119279










answered Jan 22 '13 at 22:37









Paul GrigorutaPaul Grigoruta

1,12268




1,12268












  • Any examples you might be willing to share on doing this?

    – Nirav Sheth
    Feb 4 '13 at 16:01

















  • Any examples you might be willing to share on doing this?

    – Nirav Sheth
    Feb 4 '13 at 16:01
















Any examples you might be willing to share on doing this?

– Nirav Sheth
Feb 4 '13 at 16:01





Any examples you might be willing to share on doing this?

– Nirav Sheth
Feb 4 '13 at 16:01

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f27%2fholepunching-of-header-in-magento-store%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

БиармияSxpst500bh2ntaf! 3h2r