All Questions
48,315 questions
162
votes
10
answers
192k
views
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 ...
143
votes
21
answers
326k
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 ...
111
votes
6
answers
47k
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 ...
106
votes
4
answers
58k
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/...
103
votes
13
answers
40k
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
//...
98
votes
5
answers
17k
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 ...
91
votes
30
answers
138k
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?
89
votes
17
answers
162k
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 ...
89
votes
12
answers
201k
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 ...
80
votes
22
answers
140k
views
How to check if customer is logged in or not?
How to find if a customer is logged in or not in Magento 2.
If the customer is logged in then how to get customer data from a session?
79
votes
14
answers
270k
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 ...
76
votes
2
answers
18k
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/...
74
votes
9
answers
69k
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 ...
72
votes
13
answers
29k
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 ...
71
votes
8
answers
69k
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/...
70
votes
13
answers
188k
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?
68
votes
4
answers
54k
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....
67
votes
13
answers
116k
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 ...
62
votes
8
answers
68k
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 ...
61
votes
6
answers
72k
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"&...
61
votes
6
answers
104k
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 ?
60
votes
3
answers
30k
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 ...
59
votes
18
answers
124k
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 ...
58
votes
4
answers
27k
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 ...
55
votes
12
answers
99k
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.
55
votes
3
answers
31k
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 ...
55
votes
3
answers
18k
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
...
52
votes
3
answers
10k
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.
52
votes
8
answers
45k
views
How to Override Core Block, Model and controller in Magento2
I'm stuck in overriding core model Blocks and Controllers in Magento 2.
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. ...
51
votes
13
answers
153k
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 ...
51
votes
3
answers
20k
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 ...
50
votes
18
answers
93k
views
Magento 2: Safe and easiest way to disable Compare products & Wishlist Module
I am building Magento 2.0 only to sell 2 of my products online. The compare products and wishlist module is irrelevant for me.
How I safely and easily remove those modules? I dont want to hack the ...
49
votes
3
answers
105k
views
Remove block from layout XML 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 ...
48
votes
6
answers
106k
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()
48
votes
2
answers
6k
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 ...
46
votes
7
answers
69k
views
Magento 2: How can I deploy my theme only
I was using this for deploy the content but it is taking too much time.
php bin/magento setup:static-content:deploy
then I figure out adding the language make fast but it still deploy all the ...
46
votes
8
answers
90k
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 ...
46
votes
14
answers
69k
views
Magento 2: How to truncate customers, products, reviews and orders table
Does anyone have list of tables I need to truncate to delete all test customers, products, reviews and orders in Magento 2 ? I'm looking for something similar to Clearing Magento after testing .
46
votes
17
answers
13k
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....
45
votes
6
answers
51k
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 ...
45
votes
8
answers
79k
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 ...
45
votes
1
answer
2k
views
Magento 2 Adminhtml spreading forms across multiple tabs
I'm attempting to create a backend module, where in my edit page I use admin-2column-left layout.
I want to have a form on each tab, but I don't know how I can do this.
Ideally, I would like to know ...
44
votes
18
answers
82k
views
Magento 2.2: Unable to unserialize value?
Running into issues on a site running Magento 2.2.0-rc3.0/PHP 7.0.23
The following issue occurs with all 3rd party extensions either enabled or disabled.
When adding an item to comparison from ...
44
votes
7
answers
95k
views
Add a static image on PHTML page and CMS Blocks : Magento2
How I can Add a static image on PHTML page and CMS Blocks into Magento2?
in Magento 1.x it was possible using $this->getSkinUrl('images/xyz.jpg')
I am trying following method into Magento2
In Phtml ...
42
votes
3
answers
90k
views
Extending / Overriding JS in Magento 2
As Magento2 is using RequireJS for loading scripts, and there's no more skin folder, I've stuck with a problem:
How can I replace Magento's module JS file by my modified version?
For example — the ...
42
votes
3
answers
80k
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?
42
votes
4
answers
25k
views
What is mview in Magento 2?
First of all what I know :
Index management is useful for increasing store performance.
EAV has one disadvantage.it will store data in different tables. So that retrieving data is time-consuming.
So ...
42
votes
1
answer
7k
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 ...
41
votes
7
answers
115k
views
How to load product by SKU in magento 2
It's pretty basic, but I can’t find a working example on Stackexchange or google. I want to load a product from a helper or block. I already tried some things like:
$objectManager = \Magento\...
41
votes
31
answers
158k
views
Magento 2.4.0 - Getting Error Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
I am getting below error while installing Magento 2.4.0 using command line.
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
I have run below two commands.
...