2

I have been working with project where client requires dynamic pricing to be displayed on each product depending up on customer region and customer type. The issue is when i enable full page cache that price block get cached for every customer and display same price for non logged in and logged in user.

I want to hole punch price.phtml file block but i am unable to find the exact name of same block.

I have tried searching solution everywhere but i haven't found any.

How can i hole punch price block with any full page caching mechanism.

  • You can get help here stackoverflow.com/questions/9120413/… – Arunendra Feb 29 '16 at 7:39
  • 1
    What full page cache solution are you using? Are we talking Community Edition with a third party FPC? Is so which FPC extension are you using? or a very old Enterprise Edition with native FPC? – Dave Farthing Feb 29 '16 at 8:30
  • I am using extendware full page caching module – Keyur Patel Feb 29 '16 at 9:15
  • 1
    @KeyurPatel, You can contact to extendware support team. They will solve your problem. – Arunendra Feb 29 '16 at 9:31
  • @Arunendra, This is customization as per our requirement, they are not giving any support for personal customization. – Keyur Patel Feb 29 '16 at 9:43
0
+50

You should be able to find your answer here:

As others mentioned since this is a 3rd party module, most won't be able to offer much help.


EDIT

https://extendware.groovehq.com/help_center

  • 1
    @BOOMER, link you have provided is not working. – Keyur Patel Mar 1 '16 at 6:00
  • @KeyurPatel It was working yesterday and appears to be an exception error global on their site, it is a link to their knowledge base on how to hole punch with their module. I'd suggest trying a bit later or reaching out to them to let them know it's down. – B00MER Mar 1 '16 at 15:11
  • 1
    @Boomer, the link was really helpful. i have also followed the answer given in following link and i am able to hole punch perticular block from instruction. magento.stackexchange.com/questions/53553/… – Keyur Patel Mar 4 '16 at 7:06
  • 1
    @KeyurPatel updated, thanks for pointing that out! – B00MER Apr 4 '18 at 22:55
0

To enhance dynamic functionality in Magento 2 that bypasses the full page cache feature, I have written hole punch feature that may help you to see a working example. (see https://bitbucket.org/magstaging/punchhole for more details

step 1: create a model that implements \Magento\Customer\CustomerData\SectionSourceInterface and implement the function getSectionData

class APIData implements SectionSourceInterface
{
    public function getSectionData()
    {
        return [
            'result'=> $this->getMyCustomerDynamicData()
        ];
    }
}

step 2: define in a frontend di.xml a section node for the model Magento\Customer\CustomerData\SectionPool

<?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\Customer\CustomerData\SectionPool">
        <arguments>
            <argument name="sectionSourceMap" xsi:type="array">
                <item name="dynamic-data" xsi:type="string">Mbs\PunchHole\CustomerData\DynamicData</item>
            </argument>
        </arguments>
    </type>
</config>

step 3: enable the node to be activated with an action (for instance checkout/cart/add

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="checkout/cart/add">
        <section name="dynamic-data"/>
    </action>
</config>

step 4: create a phtml template that will use your node

<script type="text/x-magento-init">
    {
      "*":{
          "Magento_Ui/js/core/app": {
              "components": {
                  "dynamic-data": {
                      "component":"Mbs_PunchHole/js/jspart"
                  }
              }
          }
      }
    }
</script>

<div data-bind="scope: 'dynamic-data'">
    <div data-bind="text: showMyDynamicResult()"></div>
</div>

step 5: create a js file in view/frontend/web/js/jspart.js

define( [ 'uiComponent', 'Magento_Customer/js/customer-data' ], function (Component, customerData) { 'use strict';

    return Component.extend({
        data: function () {
            const v = customerData.get('dynamic-data');
            return v().result || 0;
        },
        showMyDynamicResult: function () {
            return this.data();
        }
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.