All Questions
12 questions
0
votes
1
answer
67
views
Best method to use helper in any template
It seems to be impossible to use a helper in the template Magento_Catalog\templates\product\list\items.phtml.
I have tried it via argument injection:
app\design\frontend\company\base\Magento_Catalog\...
0
votes
1
answer
703
views
`$this->getViewFileUrl` adding en_us to a url
I'm trying to add an image from my theme in template like
<img src="<?php echo $this->getViewFileUrl('Vendor_Theme::images/image.svg'); ?>" />
But this url adds en_us. How can I ...
2
votes
1
answer
770
views
Adding custom logic to phtml
Very often it is needed to add some custom logic to templates. For example it can be checking if customer is logged or some information about product - if it's already bought by current customer or if ...
10
votes
3
answers
5k
views
Magento 2: proper use of helpers
I'm starting to see more and more people declaring helpers classes in order to be able to use the following in the template files:
$this->helper('Path/To/Helper/Class')->customMethod();
This ...
5
votes
3
answers
700
views
Where should i put my function if i need it only in one Template?
I got a template called dashboard.phtml and i want to add a function there.
I thought it was a bad practice to write it directly in the template it self so where should i put it?
The class for this ...
7
votes
3
answers
8k
views
Correct way of getting helper in template of custom block
What is the correct way of getting a helper in a template file of a custom block?
In Magento_Search module there is a block:
<referenceContainer name="header-wrapper">
<block class="...
7
votes
1
answer
9k
views
Difference between $this->helper and Mage::helper
Is the following codes in the phtml $this->helper('catalog/category') and Mage::helper('catalog/category') returns the same object?
What is the meaning of using $this->helper() and Mage::...
1
vote
1
answer
805
views
What's your take on using a custom helper in templates? [closed]
I'm faced with a problem where I can either make a helper in my extension to do some simple task or override multiple block class functions. This is a utility function, so I would typically make a ...
1
vote
1
answer
219
views
Why Is This Custom Module Helper Returning the Same Value In A Loop In A Template?
I have a custom module, called JLS_Composers, which is used to input a "composer." Each product can have one or more Composers associated with it (which is accomplished in the Product edit page). I ...
0
votes
1
answer
3k
views
Access input field values from form template in helper/controller classes
In a Magento checkout template there is a html tag for payment form:
<ul class="form-list" id="payment_form_testmethod" style="display:none;">
<li>
<input class="checkbox" ...
1
vote
2
answers
5k
views
Call helper method from cms template
Is it possible to call a helper method to output a variable in a cms template?
Similar in fashion to the way helpers can be called in layout files such as:
<node helper="myhelper/myhelpermethod" /...
3
votes
1
answer
4k
views
Use template/block in a helper
I have a helper with this method to get the items in a customer's cart
public function getCartData()
{
//Get cart DATA
$quote = Mage::getSingleton('checkout/session')->getQuote();
$...