9 votes
Accepted

How to retrieve variable from CMS page in Magento 2

You can use in Magento 2 like this {{block class="Magento\Framework\View\Element\Template" name="blockname" template="Vendor_Module::test.phtml" my_vars="123,456"}} Now you can get the data by ...
Prince Patel's user avatar
  • 22.7k
7 votes
Accepted

Magento 2: Pass variable from phtml to js

In your .phtml please add following code. <script type="text/x-magento-init"> { "*": { "Magepow_Ajaxcart/js/view/minicartaddons": { "maxpriceShipping": <?= /* @...
Aasim Goriya's user avatar
  • 5,444
6 votes
Accepted

Getting at variables from CMS block insertions

You can definitely use the code you pasted: {{block type="core/template" template="page/html/jobappform.phtml" a="1" b="2"}} And then in your template you can do: $this->getA(); $this->getB()...
Raphael at Digital Pianism's user avatar
5 votes
Accepted

How to get value of a variable when variable has been sending through layout handle in Magento 2

I didn't test yet but that is same as magento1. try to get it by. $this->getCheck(); or $block->getCheck();
Qaisar Satti's user avatar
  • 32.5k
5 votes
Accepted

product ids separate with # on success page

Go to the success page template app/design/frontend/base/default/template/checkout/success.phtml (for base theme) Aafter <?php if ($this->getOrderId()):?> add: <?php $order = ...
Siarhey Uchukhlebau's user avatar
4 votes
Accepted

updating custom variable value programatically

try this: $code = 'variable-code'; $variable = Mage::getModel('core/variable')->loadByCode($code); $variable->setName('Variable Name') ->setHtmlValue('Html Value') ->...
Abdul's user avatar
  • 9,701
4 votes
Accepted

How to set session variable

You can use to set and get custom session value like below $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $catalogSession = $objectManager->get('\Magento\...
Ansar Husain's user avatar
  • 3,409
4 votes

Passing magento username and email variables into js script (Magento ver. 2.1.8)

Assuming that this is a JavaScript Component in the Magento sense of the word, you can basically "insert" it into any HTML element. Let's say you want to put your chat inside a div you can do ...
Jorge1o1's user avatar
  • 331
4 votes
Accepted

Magento2.3 : Email template address variable not displays the value

For email template changes following section For Guest User {{trans "%customer_name," customer_name=$order.getBillingAddress().getName()}} For Customer {{trans "%customer_name," ...
Vijay Khirade's user avatar
3 votes
Accepted

Magento 2 - How can I define constants or variables once and reuse them in a custom module?

There are different ways like: a) helper class 1) Declare the helper class and define your constants and variables in it. 2) Inject it as a dependency in all your classes. 3) Now the constants ...
Pankaj Bhope's user avatar
  • 1,546
3 votes

Magento 2 - How can I define constants or variables once and reuse them in a custom module?

Pick a PHP class in your module and define the constant in there using const keyword. For example const LOG_FILE = 'file/path';. You can access it from anywhere like \Class\Name::LOG_FILE.
Aaron Allen's user avatar
  • 9,009
3 votes
Accepted

Where do we store persistent single variables in Magento 2 (module settings)?

Magento provides a facility to persist configuration values like tokens, passwords, URLs etc. This is the System (Store) Configuration (Menu > Stores > Configuration). See the /etc section of this ...
nikola99's user avatar
  • 518
3 votes
Accepted

Magento 2 : How to call block file in order email with order variable?

You can achieve this from just a block calling from email and pass the order variable in that block and do you calculation like : in email template just use this to call block {{block class="Magento\...
Ashish Jagnani's user avatar
3 votes
Accepted

How to add new Template Variable in magento

Template variables are comes from email template comments, To add new template variable we need to add it to email template comment section(at top of email template html) as like below: <!--@...
Ranjit Shinde's user avatar
3 votes

Show review count outside of review template

Try this code in your .phtml file $product = Mage::registry('current_product'); $rc = $product->getRatingSummary()->getReviewsCount(); Hope this helps.
Ihor Klymchuk's user avatar
3 votes

Getting the shipping method code in transactional emails

Not sure I follow 100%, but I'll take a shot at it. {{var shippingMethod}} is not a standard variable on sales email templates, so it must be something you already inject as custom. Default ...
Rick Buczynski's user avatar
3 votes
Accepted

Magento 2: format var invoice.created_at

I solved the problem by adding a new function to Model/Order/Invoice.php: public function getInvoiceDate(){ $cdate = $this->getCreatedAt(); $invoiceDate = date('d. M. Y', strtotime(...
crrdr's user avatar
  • 46
3 votes
Accepted

Getting the Store Name in a Block

We can get store name like this: In Phtml: $storeName = Mage::app()->getStore()->getName(); In Cms Page: {{config path="general/store_information/name"}} Don't forget to configure your ...
Shubham Khandelwal's user avatar
2 votes

Identify default variables from less files

you can create a new variable for that set margin 0 it to. magento\lib\web\css\source\lib\variables_typography.less in this file find following code. line no 67 approx here is set default margin ...
Suryakant's user avatar
2 votes

How to add new Template Variable in magento

You add custom variables by accessing System > Custom Variables menu.
Raphael at Digital Pianism's user avatar
2 votes

How do I” Pass variable between .phtml files?

I dont know why you want to do this But you can use Magento registry for this. Set data to registry Mage::register('name-of-registry-key', $postdata); Get your data $var = Mage::registry('name-of-...
Murtuza Zabuawala's user avatar
2 votes
Accepted

How can I use my own custom system settings in e-mail templates?

I found the problem. In my source model I hooked into the toOptionArray()-method, but this had to be the getData()-method: public function afterGetData(\Magento\Email\Model\Source\Variables $subject, ...
Giel Berkers's user avatar
  • 12.2k
2 votes
Accepted

Magento 2 : Can we pass multiple variables in layout handle?

Yes, you can pass multiple variables in layout handle. {{layout handle="sales_email_order_invoice_items" invoice=$invoice order=$order}} For reference : /vendor/magento/theme-frontend-luma/...
Krishna ijjada's user avatar
2 votes

Magento 2 : How to call block file in order email with order variable?

This was my method for getting product attributes into my email template. I utilize the productRepositoryInterface to pull custom attributes that we store as JSON strings. Our business uses core ...
David Stillson's user avatar
2 votes

Hide {{var comment}} when field empty in email

{{if comment}} {{var comment}} {{/if}}
Konstantin Gerasimov's user avatar
2 votes
Accepted

Magento 1.9 {{var payment_html}} alternative

You cannot the payment html directly form the order because there is a block involved. You can generate the html like this: Let's say $order is your order object. $paymentBlock = Mage::helper('...
Marius's user avatar
  • 198k
2 votes

Magento2 variable in transactional email

You can get customer email by below line, {{var order.getCustomerEmail()}}
Rakesh Jesadiya's user avatar
2 votes
Accepted

Magento 2 | Variable with StoreViewCode

use following variable to get url with store code : {{store direct_url=""}} Also this will work : {{store url=''}}
Naveed Asim's user avatar
  • 3,637
2 votes
Accepted

How to get value in function that is retrieved and stored in a variable of another function in same class | Magento 2

Instead of set public, try with set variable private. class Observer implements ObserverInterface { private $orderId; public function __construct( \Magento\Framework\Registry $...
Rohan Hapani's user avatar
  • 17.4k
2 votes

how to validate custom fields using variables in magento 2

<input type = "text" id ="price1" ?> <input type = "text" id ="price2" ?> <div id = "error"></div> <script> $(document).ready(function(){ $("#price2")....
ASQ's user avatar
  • 1,052

Only top scored, non community-wiki answers of a minimum length are eligible