Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Get controller url in email template file magento2

    Here, we are discussing how to get a controller url in mail template file according to store.

    For example: If you want to add a link of custom controller or store wise login url, then you can follow given method.

    Here, we write the code to send email to a customer in which we add a customer login url according to store.

    first create a method in which you call email template file method to send mail :


    $customerId, is a customer id.

    $customerModel, is a customer model, holds the data of the customer which have id $customerId.

    $customerStoreId, is a store id of a customer.

    $emailtempvariables is an array holds the values which you want to pass in your email template file.

    sendMail is a function in which you write the code to send an email.

    You can check our blog “create custom mail template in magento2
    Now, create your template file with the code:


    rest_url, is variable in which we get the url according to the store, and it return customer login url according to store.

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again