1
votes

I have added compare products programmatically and they are showing in compare action as below:

http://example.com/catalog/product_compare/index/

But Header compare items section not showing. below refer below image. https://prnt.sc/itlyaf

is related to customerData.get('compare-products') ?

how to update this header section even I have cleared all the cache?

1

1 Answers

1
votes

You can update a particular data section by using "Magento_Customer/js/customer-data".

For 'compare-products' section you can use below code.

<script type="text/javascript">
    require([
    'jquery',
    'Magento_Customer/js/customer-data'   
], function ($, customerData) {
    'use strict';
    customerData.reload('compare-products');
});
</script>