Linked Questions

11
votes
1answer
2k views

why i should not use object manager directly in magento2? [duplicate]

Magento 2 uses dependency injection means when ever client required any services we have to pass in constructor. So magento take care like automatically create objects recursively.. but there is a ...
0
votes
2answers
549 views

Magento2 performance load : Constructor initialize or use Object manager Directly? [duplicate]

It seems to be differnt ways to call the helper or model classes. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $objectManager->create('Magento\Framework\Pricing\Helper\...
-3
votes
1answer
488 views

Is it recommended to use object manager by passing into constructor as a dependency? [duplicate]

As of my observation, core team used the object manager as added Example flow taken from module-cms public function __construct( //..... \Magento\Framework\...
-1
votes
2answers
97 views

Magento 2 : what are the place use object manager. what are the place need to avoid? [duplicate]

i have written code using object manager in Block. i am not sure it is best practice. what are the place use object manager. what are the place we need to avoid Any one suggest please
2
votes
1answer
89 views

ObjectManager in category init [duplicate]

Why Magento is using $this->_objectManager->create() directly in function _initCategory in file vendor/magento/module-catalog/Controller/Adminhtml/Category.php? protected function _initCategory(...
0
votes
1answer
76 views

Magento 2.2 Can we use Object Manager in Controller or Block? [duplicate]

To get product data, I am using object manager in my controller, but I read in docs that we should not use it directly. <?php pubic function execute() { $objectManager = \Magento\Framework\...
0
votes
0answers
20 views

Why we use Dependency injection? [duplicate]

Why we use Dependency injection?. because also do work with use of object so why we use?. Already flow devdocs but still little confuse.
0
votes
0answers
17 views

Where we use objectmanager in magento 2? [duplicate]

In magento 2 do not use objectmanager but in core some files are uses ,i need where we use objectmanager
69
votes
18answers
71k views

How to check if customer is logged in or not in magento 2?

How to find if customer is logged in or not in Magento 2. If customer is logged in then how to get customer data from session?
9
votes
5answers
26k views

Magento 2 - Get Subcategories of Specific Parent Category

What I'd like to do is grab all of the child categories of a specific parent category. I'm assuming the best way to do this is by using the parent's ID and of those child categories that are returned, ...
12
votes
3answers
15k views

Magento 2 - What is the use of formkey

I see this line of code inside the login form. <?php echo $block->getBlockHtml('formkey'); ?> What is the use of it? Is it more secure? Is it a must for form post?
17
votes
6answers
11k views

How to get store phone number in magento 2

I want to display phone number saved in magento admin in frontend in magento 2. Like in magento 1.9 its like $storePhone = Mage::getStoreConfig('general/store_information/phone');
10
votes
4answers
15k views

Magento 2 Get Cart Quote Total in minicart.phtml

I'm trying to get the cart quote total in minicart.phtml, but I'm having no luck. I'm injecting Magento\Checkout\Model\Cart. Here's my code: $this->cart = $cart; $cartQuote= $this->cart->...
7
votes
3answers
15k views

Magento2: Load Model Data By Another Field

I have below table named "messages". id | posts_id | message_description | created_at ----------------------------------------------------------------------------- 1 1 test1 ...
11
votes
4answers
6k views

Magento 2 Helper instance

When I think I got my head wrapped around the DI system from Magento 2 something comes up and un-wraps it. I see in the core code different ways to access a helper. For example in Magento\Catalog\...

15 30 50 per page
1 2 3 4 5 6