2

I am trying to get the custom session data of Customer in a javascript file. As I am passing 'Magento_Customer/js/customer-data' as dependency in order to retrieve the data.

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



    return Component.extend({
        defaults: {
            template: 'Mymodule_Company/myTemplate'
        },
        initialize : function(){
           this._super(customerData.getData());
           console.log(customerData.getCustomerInfo());
        }
    });
}
);

I want to get a custom variable just like i set up in my php file :

$this->customerSession->setMyCustomValue("my custom variable");
  • Did you mange to get it work? – Adarsh Khatri Jul 31 at 2:23
-1

It depends on what you want, if you want like the cart section you could use it in the following way:

customerData.get('cart')();

You could add custom data to the customer data and then retrieve it with like:

customerData.get('sectionData');

More info: http://devdocs.magento.com/guides/v2.2/extension-dev-guide/cache/page-caching/private-content.html

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.