Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
1 answer
2k views

Override Helper in Magento2 - Vendor\Module\Helper\Data doesn't extends Magento\Framework\App\Helper\AbstractHelper

May be i'm missing something really small. Here is a class Class1 namespace Vendor\Module\Helper; class Class1 extends AbstractHelper { /** @var Client */ private $client; /** @var ...
Kingshuk Deb's user avatar
  • 1,214
0 votes
1 answer
634 views

Injecting Helper causes "Undefined constant" and "'generated' directory permission is read-only"

When I inject the helper class it gives me the below errors. If I remove the reference to the Helper class in the constructor then everything works perfectly. controller file: /var/www/html/app/code/[...
Brenda.ZMPOV's user avatar
2 votes
2 answers
3k views

Magento 2: Helper not working

I am learning how to use dependency injections to get the classes I need. The following will work when creating a controller. ... use Magento\Framework\App\Action\Context; class Index extends \...
Typhado's user avatar
  • 712
0 votes
2 answers
101 views

Creating helper object in the same class magento 2

How to create object in the constructor from the same class? <?php namespace Vendor\CatalogSearch\Helper; use Magento\Framework\App\Helper\AbstractHelper; class Data extends ...
Sushivam's user avatar
  • 2,639
8 votes
2 answers
433 views

Annoyed by tons of classes for DI in constructors of Magento 2 - is there a better way?

At this time I am annoyed of writing similar constructors en masse like the following within my modules. public function __construct( \Magento\Framework\Model\Context $context, \Magento\...
bukart's user avatar
  • 308
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="...
zitix's user avatar
  • 2,192
1 vote
3 answers
3k views

Magento 2 - Accessing a helper without using constructor injection

Is there a clean way to initiate and access a custom helper without using the constructor? Currently I instantiate the custom helper using the constructor of the model as shown here as the accepted ...
rofavadeka's user avatar
27 votes
5 answers
29k views

Instantiating Helpers in Magento 2

The latest builds of Magento 2 have done away with the Mage class. This mean we've lost the Mage::helper method. Is there a replacement technique (helper factory?) for instantiating helpers in ...
Alana Storm's user avatar
  • 44.4k