Skip to main content

Sections that can be updated when using Ajax request Magento2

In Magento 2, a lot work has been done in improving the response time and Sections are a part of it. Magento sets customer related data in local storage of browser in key value pair. Each key is known as section. In this post we will what sections we can update 

We can use all below sections in system.xml file 

  • messages
  • customer
  • compare-products
  • last-ordered-items
  • cart
  • directory-data
  • captcha
  • instant-purchase
  • persistent
  • review
  • wishlist
  • recently_viewed_product
  • recently_compared_product
  • product_data_storage
  • paypal-billing-agreement
  • checkout-fields
  • collection-point-result
  • pickup-location-result

 

put your "sections.xml" inside 

etc\frontend\

 

<?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="outstanding_payments/invoice/payselected/">
        <section name="cart"/>
    </action>
    
    <action name="{frontname}/{controller}/{action}/">
        <section name="cart"/>
        <section name="wishlist"/>
    </action>
    
</config>