Questions tagged [class]

A template for creating new objects that describes the common state(s) and behavior(s). NOT TO BE CONFUSED WITH CSS CLASSES. Use [css] instead.

Filter by
Sorted by
Tagged with
15
votes
1answer
9k views

DI & Extending a Block on Magento 2

I seem to be struggling to grasp Magento 2 dependency injection with blocks, every time I try to extend a block that isn't \Magento\Framework\View\Element\Template I end up with errors. I want to ...
3
votes
3answers
11k views

Fatal error: Class Helper_Data' not found in app\Mage.php

Please help me guys to fix it : Fatal error: Class 'Mage_Parcelamento_Helper_Data' not found in C:\wamp64\www\magento\app\Mage.php on line 547 Error log Warning: include(Mage\Parcelamento\...
7
votes
1answer
7k views

Usage of getsingleton() and getModel()

Is there a set of guidelines that I can go by to decide when I should use mage::getModel() and mage::getSingleton() From what I can tell it seems as though getSingleton either gets an existing ...
2
votes
2answers
2k views

Calling Grandparent Class in magento class inheritance

UPDATE: This issue was finally tracked down as a class inheritance issue. The original code in class becomes invalid, due to fact that the class inheritance has been updated, and the 'parent::parent' ...
6
votes
1answer
5k views

Magento 2: Overriding Block class – not generating output

I'm trying to override the module-catalog/Block/Product/View/Options/Type/Select.php class with a new version which includes a few other bits of custom php (adding HTML classes and IDs to the ...
5
votes
3answers
2k views

Magento 2 : add custom class on checkout page shipping address field

I am using magento 2.1.7. I want to add one class in country select box on checkout page shipping address. If anyone knows please help to add class.
3
votes
1answer
6k views

Where are class constructor parameters defined in Magento2?

If you see AbstractExpress class for PayPal payment method, you could see: /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @...
2
votes
1answer
1k views

Dynamically instanciate class with arguments

I am actually trying to instanciate a class dynamically with these arguments. Here is the code I use in class A: /** @var string $source */ $source = '\Foo\Bar\My\Class'; // Dynamic value that I ...
2
votes
3answers
20k views

How do you change the number of product columns?

I want to change the number of products that are shown. But I don't want to hard code this into the theme. This: <ul class=​"products-grid products-grid--max-4-col first last odd">​…​</ul&...
1
vote
1answer
4k views

Magento Including External library

I have tried Joreon Vermeulen's method https://stackoverflow.com/questions/6417394/how-to-add-a-3rd-party-library-to-magento to autoload classes but to no avail. Now in my custom autoloader I get the ...
9
votes
3answers
638 views

What (type of) classes are generated in Magento 2?

In Magento 2 there are a set of classes that are generated automatically and stored in var/generation and they are used in the core code. While trying to create a custom module by replicating one of ...
2
votes
1answer
2k views

Extending an abstract block class

I'm modifying getCountryHtmlSelect() through a custom class that extends another core class that extends Mage_Checkout_Block_Onepage_Abstract. Here's the class with the customized code: local/...
0
votes
1answer
229 views

Magento 2: New module causing crash

I'm trying to override the module-catalog/Block/Product/View/Options/Type/Select.php class with a new version which includes a few other bits of custom php. I have done the below and then run the php ...
0
votes
2answers
699 views

How to use require_once in magento 2

I'm trying to include a PHP class in magento 2. I use a require_once and create a folder lib in the root of my module and there I put the folder that contains the class lib/Meli/Meli.php Also try in ...