Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [global-variable]

The tag has no usage guidance.

1
vote
2answers
45 views

M2 | How to create global variable that can be used only in the same class?

The scenario is I have multiple if-conditions to create product programmatically or load at controller action. I need a single variable who's value should be updating through different functions. I ...
0
votes
1answer
41 views

How to define constants or environment variables in Magento 2.2.6?

I want to define constants to use in all my project. How to define constant or environment variables to access all over the project without any special declaration ?
0
votes
0answers
14 views

PHP Variable Value in js in magento2 [duplicate]

I have created a function in my Block and the function return in j son now I want to get this block function return in my js file which I create in the js folder.
2
votes
1answer
40 views

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

I want to use $orderId value in other functions. Here is class <?php namespace vendor\module\Observer; use Magento\Framework\Event\ObserverInterface; class Observer implements ObserverInterface ...
0
votes
1answer
120 views

How to fix "Direct use of $_SERVER Superglobal detected' in Magento 1

Using the $_SERVER super global in an extension causes the following guideline error Direct use of $_SERVER Superglobal detected I know the alternative for Magento 2 but how do you solve this for ...
1
vote
3answers
340 views

How can I set a global variable in Magento 2?

The scenario is I want to set my variable to a global variable from a phtml file and call in a module file or block file. So what would be some code or tutorial link that I set my variable to global ...
3
votes
1answer
910 views

Magento 2 - Set global variable

I want to know if it's possible to add a global variable all through the site (so that if I need to change it, I would only need to do it once). It's for an URL.
0
votes
1answer
663 views

Magento 2: Global variable doesn't work with RequireJS

I'd create a HTML document with a script tag and add this URL <script src ="https://assets.pagar.me/pagarme-js/3.0/pagarme.min.js"></script> so, call the global variable pagarme in ...
1
vote
2answers
384 views

Magento global variables appear empty

I have a custom module that subscribes to an event called catalog_product_collection_apply_limitations_after. In the observer I am setting a variable (E.g $_GET['test'] = true) Then later in my ....
2
votes
1answer
158 views

Refactoring Mage::registry('current_shipment')

I'm working on refactoring a backend extension which uses the global Mage::registry('current_shipment') to retrieve the current shipment for printing. I'd like to change this line to something that ...
4
votes
1answer
1k views

how to fix "Direct use of $_SERVER Superglobal detected' in Magento 2

I am having problem with module approval. and magento connect validation report generates following message Direct use of $_SERVER Superglobal detected how can i use alternate for $_SERVER['...
2
votes
3answers
1k views

Use a custom variable in a category description

I recently created a custom variable named storecount - which I'll be programatically increasing for every store that is added to my store locator plugin. I'd like to show this in various locations ...
0
votes
2answers
756 views

How to use a variable set in “view.phtml” in a controller file?

I'm using Magento 1.4.1.1. The following contains a useful URL when run in "template/catalog/product/view.phtml". $this->helper('core/url')->getCurrentUrl(); When I try to get the same URL by ...
1
vote
1answer
60 views

assigning model variable from cms

I'm attempting to assign some variable used in a custom modules model. This variable will be defined in the CMS page. How can I pass this variable in such a way as it will be used in the model? I'm ...
0
votes
1answer
1k views

Custom text in mail template depending on shipping description

I want to insert custom text in email template, if shipping title = 'Pickup'. I have followed this guide to make if statement work in mail template. https://stackoverflow.com/questions/4797394/magento-...
0
votes
1answer
328 views

Store email variable for insertion in block?

I want something like this in a CMS block: <a href="mailto:{{url:store1-general-email}}">Send an email</a> ...which should result with a proper insertion of the General Email account for ...
0
votes
2answers
3k views

customer name is not visible in newsletter conformation mail

We want to contact our registered customers in the newsletter confirmation mail with their names. Every template we tried to configure the names weren't shown in the mails. Anybody out there who's ...
0
votes
1answer
314 views

Initializing and updating vars used in a phtml. What is the proper way?

I am implementing a quotation form. I then declared a module in which I defined a phtml template containing the form, the computed price display and the javascript/ajax script. I also have defined a ...
2
votes
1answer
689 views

Why I can't access global variable in my observer?

I have a custom module. In its controller I set a global variable as shown below public function someAction() { if (<some_condition_met>) { $id = 12; $item = Mage::getModel(...