Stack Exchange Network

Stack Exchange network consists of 174 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 [magento2]

General questions about Magento 2, not specific to a minor version. Use this tag to distinguish from Magento 1. If you have issues with a specific version, please use the appropriate 'magento-2.x' tag instead. Functionalities between Magento 2 minor versions might differ.

104
votes
7answers
63k views

Magento 2: to use or not to use the ObjectManager directly?

Ok, so yesterday we had a big talk with other people from the Magento community regarding the direct use of the ObjectManager in classes/templates. I'm already aware of the reasons why we shouldn't ...
84
votes
13answers
75k views

Magento 2: Replacement for Mage::log method?

In Magento 1, if you wanted to send a message to the logs, you'd use a static method on the global Mage class. Mage::log($message, Zend_Log::DEBUG, "my-log-file.log"); Is there an equivalent in ...
83
votes
11answers
20k views

How can I bootstrap Magento 2 in a test.php script?

In magento 1 I could create a file where I only needed to instantiate the Mage_Core_Model_App class and then I could add my "dirty" code for test purposes. Something like this test.php: <?php //...
83
votes
5answers
11k views

GIT and deployment strategy Magento2 projects

With Magento 1 I used a deploy tool that pulled in the GIT repo, ran commands like modman deploy-all and made sure the var directory was writable. For the .gitignore I used this one which worked ...
75
votes
4answers
36k views

Explanation of UI Component Grid in Magento 2

Is there a good explaination and/or sample of the bare minimum configuration needed to create a UI Component Grid in Magento 2? I know there are myriad core components, such as ./vendor/magento/...
67
votes
13answers
28k views

Is Magento ready for PHP 7?

PHP 7 is reaching beta status and lots of testing is going on at the moment. Given that Magento caught up within the last year from "runs only on PHP 5.3" to "fully compatible with PHP 5.6", I would ...
66
votes
9answers
143k views

Magento 2 Reindexing - One or more indexers are invalid. Make sure your Magento cron job is running

I couldn't find the way to do reindexing in mass actions on magento 2. Seems like you need to run it from cronjob. Is there an alternative way to reindex data in magento 2 from backend or command ...
62
votes
5answers
13k views

When Should We Use a Repository and Factory in Magento 2?

I have gone through a couple of tutorials in Magento 2, and this confuses me a little. I can see there are basically two ways by which we can read/write business entities: Retrieve Data Using A ...
60
votes
2answers
7k views

Magento 2 @escapeNotVerified

I see a lot of occurences of this comment /* @escapeNotVerified */ in the template files for Magento2. Does it have a special meaning? Is there any use for this? Examples: https://github.com/...
48
votes
11answers
103k views

Magento 2 folder/file permissions

I suspect that the permissions might have gotten messed up on my Magento 2 installation. On the old versions I would run the following command to make folders 755 and files 644: find . -type f -exec ...
47
votes
13answers
69k views

How to get Magento 2 base URL?

In Magento 1 Mage::getBaseUrl();, but in Magento 2 I have to pass responsible class object type in constructor. I don’t have the idea which class I have to pass?
47
votes
7answers
22k views

How to create custom Log file in Magento 2?

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log. Magento 2 has changed to ...
47
votes
3answers
11k views

Deprecated save and load methods in Abstract Model

I see that in the develop branch of the Magento 2 repo the methods load and save from Magento\Framework\Model\AbstractModel class are deprecated. But there are a gazillion classes in the core that ...
46
votes
3answers
6k views

Run tests for a specific module in Magento2

Running the tests for Magento to using php bin/magento dev:tests:run takes a lot of time. Is there a way to run the tests for a specific module only? I'm a noob in (unit) testing so have mercy.
44
votes
7answers
36k views

Magento 2 backend session timeout

In Magento 1.x the backend session timeout was set via: Backend -> System -> Configuration -> Admin -> Security -> Session Lifetime (seconds) Initially, my question was how to set this ...
44
votes
15answers
10k views

Security Patch SUPEE-10570 - Possible issues?

Magento has released a new security patch for M1, and updates for M1 and M2. What issues should I look out for when upgrading or applying this patch? SUPEE-10570 SUPEE-10570, Magento Commerce 1....
43
votes
15answers
47k 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?
43
votes
6answers
24k views

Magento 2: Changing a Block's Template

In Magento 1, as a module developer it's possible to change a block's template using layout XML code something like this <reference name="block_to_change"> <action method="setTemplate"&...
43
votes
2answers
5k views

Magento Event Observers: Singleton versus Model

So Magento offers 2 ways of declaring an observer. Singleton and Model (new instance) by specifying the <type> tag in Magento 1.x and by specifying the shared attribute in Magento 2. Magento 1 ...
42
votes
14answers
46k views

Required parameter 'theme_dir' was not passed

What is the error message: Required parameter 'theme_dir' was not passed Is it related to in Magento 2? And how can this problem be fixed?
41
votes
7answers
19k views

How to use the new repo.magento.com

I've generated a new Magento Connect key per the developer documentation instructions. How am I supposed to use this key? i.e., if I try getting info, I see the following. $ composer info magento/...
40
votes
13answers
59k views

Magento2: Re generate css file in pub/static folder

I have installed Magento 2 and set developer mode, then I have installed one module that contains css and js files. The module works fine and css and js files are rendering from pub/static folder. Now ...
40
votes
5answers
29k views

Magento 2 How to unlock reindex process

I'm making some tests in Magento reindex process and I locked the stock index process. How can I unlock this process? Design Config Grid index has been rebuilt successfully in 00:00:02 Customer ...
40
votes
8answers
35k views

How to Override Core Block, Model and controller in Magento2

I'm stuck in overriding core model Blocks and controllers in Magento2. Can any one help on this? Let's take list toolbar as example where I need to add a new sort option called sort by most popular. ...
39
votes
3answers
7k views

Magento2: what is the basic difference between plugin and preference?

I used both plugin and preference in magento2 tutorial and both are working fine but what is the basic difference between them. Code for plugin: 1.1) Add a plugin declaration into di.xml: <type ...
38
votes
8answers
34k views

'Area code not set' issue in custom CLI commands in Magento 2

I'm getting following error while updating data through CustomerRepositoryInterface [Magento\Framework\Exception\SessionException] Area code not set: Area code must be set before starting a ...
38
votes
3answers
5k views

Magento 2 as a headless solution

I want to know if there are some best practices to use Magento 2 as a headless E-commerce solution. A typical E-commerce in 2017 is to have an omni-channel solution which includes E-commerce CMS ...
38
votes
3answers
6k views

What Triggers the Generation of a Factory in Magento 2

Magento 2 contains a number of class files that are either pre-generated, or are generated on the fly. They live in var/generated These generated files include factory classes. From the ...
38
votes
1answer
6k views

How to add a new product type in Magento 2? (MageStackDay mystery question 1)

MageStackDay bonus question for 500pts Bounty AND a the possibility of winning a free Z-Ray license for a year. More info can be found >> here << The questions are provided by Magento 2 core ...
37
votes
4answers
14k views

Magento 2: how do customer sections / sections.xml work?

I recently came accross a new concept in Magento 2 that I found interesting: customer sections Some of you may have notice the presence of sections.xml files that look like this: <?xml version="1....
36
votes
8answers
45k views

How to reset lost admin password in Magento 2?

I tried to reset the admin password via Phpmyadmin in admin_user table but this doesn't seems to work. Also on chrome I am getting "This webpage has a redirect loop" error when loading admin page.
35
votes
11answers
76k views

How do I set Developer Mode in Magento 2

I'm trying to install Magento 2 but I am getting the following error: Error happened during application run. Could not write error message to log. Please use developer mode to see the message. I ...
35
votes
7answers
48k views

How to update Magento2 using composer

I can't seem to be able to update my magento2 ce using composer. I doesn't find any updates, the only one it found was 'fabpot'. I thought this was the whole point of a composer setup, so why would I ...
34
votes
4answers
20k views

How to add fee to order totals in Magento 2

The following link will describe http://excellencemagentoblog.com/blog/2012/01/27/magento-add-fee-discount-order-total/ to add fee to order totals in Magento 1. Now this functionality is moved to ...
34
votes
7answers
54k views

Magento 2 404 error for scripts and css

I have downloaded and installed Magento 2 from https://github.com/magento/magento2 But I am getting 404 error for scripts and cs located in http://localhost/magento2/pub/static/ I have checked, ...
34
votes
3answers
25k views

Enable exception printing on the webpage in Magento2

I was installing Magento 2 and got the following error. There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record ...
33
votes
3answers
40k views

Remove block from layout in Magento 2

In Magento 1 I could remove a block added by a layout file by adding this in my layout block <remove ="block_id_here" /> How can I do the same for Magento 2? As a practical exercise, let's say ...
32
votes
1answer
9k views

Magento 2 - Object manager tries to instantiate Abstract class. ( Fatal error )

Playing around with Magento 2 but run into a problem I can not wrap my head around. The object manager tries to instantiate Abstract class, this gives an Fatal Error. Does someone know what might ...
32
votes
5answers
40k views

How To add JS file in frontend for all pages

I've read 3 pages of Google Results on how to load a JS file for all pages and still am not able to do it. I've got a few doubts, hope somebody can clear them out. Do I need to create a module ...
32
votes
4answers
18k views

Magento 2: Run `setup:di:compile` **only** a Specific Module?

Is it possible to pre-generate code for one specific module? I.E. -- I can generate all the code in the system with php bin/magento setup:di:compile However, this can take a long time. I'd like to ...
31
votes
8answers
22k views

Where is Template Path Hints in Magento 2?

Just started playing about with Magento 2. Can anyone tell me where I can find the "Template Path Hints" option that used to be in System > Configuration > Developer > Debug?
31
votes
3answers
9k views

How to implement service contract for a custom module in Magento 2?

As seen in this post : Deprecated save and load methods in Abstract Model the save and load methods are deprecated in the Magento 2 develop branch. Thus, the good practice is now to be implement ...
31
votes
4answers
38k views

How to get value from `core_config_data` table in Magento 2

Magento 1.x use Mage::getStoreConfig('sections/groups/fields') get data on core_config_data table. How to Magento2 get value from core_config_data table ?
31
votes
1answer
3k views

Why is Magento 2.1.0 released before 2.0.9?

Magento has released 2.1.0 on June 23 but has released 2.0.8 (July) and 2.0.9 (Aug) after that. (https://github.com/magento/magento2/releases) Why are they releasing lower versions? If anybody knows ...
30
votes
3answers
8k views

What is the difference between type and virtualType

In the di.xml that comes with Magento2 there is a node type and a node virtualType. My questions is what is this virtualType and in what case should it be used instead of type? In some places it ...
30
votes
5answers
53k views

How to fix Magento 2 2.0.0-RC Admin page not found after installation

It's a fresh new install with a clean database. I checked the values from Magento 2 : Error 404 not found at magento 2 admin login page and it's fine too. Also tried to access it via /index.php/admin ...
30
votes
2answers
1k views

How can I change an existing modal in Magento 2

I'm trying to change the behaviour of a Modal (not Model) in Magento 2. The modal in question is advanced_inventory_modal, declared in module-catalog-inventory/view/adminhtml/ui_component/product_form....
29
votes
3answers
32k views

How to Set, Retrieve and Unset Session Variables in Magento 2?

What is the equivalent for session in Magento 1 Mage::getSingleton('core/session')->setMyValue('test'); Mage::getSingleton('core/session')->unsMyValue(); Same in Magento 2?
29
votes
4answers
31k views

Magento2 how to getRequest

In Magento 2 how to receive request array? $_POST and $_GET too as we did in Magento 1: Mage::app()->getRequest()->getPost()
29
votes
8answers
16k views

Future Support of Magento 1.9 - Coming Magento 2.0

We want to upgrade our current Magento 1.4.0.1 installation to 1.9.1.0 till autumn this year. The only thing we are unsure about is the future support of 1.9.1.0 since Magento 2.0 will be released end ...