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.

Filter by
Sorted by
Tagged with
34
votes
11answers
38k 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 .
34
votes
5answers
64k 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 ...
34
votes
1answer
24k views

How do you override LESS in a custom theme?

I've spent the better part of this week trying to find a clear guide on how to properly create a custom theme and extend exist LESS/CSS without having to copy the entire magento-blank theme. The ...
33
votes
7answers
40k 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 ...
33
votes
3answers
44k 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?
33
votes
6answers
47k 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 ...
33
votes
1answer
4k 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 ...
33
votes
4answers
21k 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 ...
32
votes
15answers
39k 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 ...
32
votes
7answers
50k views

Magento 2 - Form Validation

is there a overview for the new form validation attributes in Magento 2?
32
votes
5answers
24k views

Magento2 - programmatically add product attribute options

What is the right(official) way to programmatically add product attribute option in M2? E.g. for manufacturer product attribute. Obviously existing option would be matched by "Admin" title value.
32
votes
3answers
43k views

magento 2 how to call any block function in phtml

How can I call any block function in any phtml? For example if I want to call my custom block function in product list.phtml?
32
votes
5answers
15k views

Why can't one switch back to the default mode on Magento 2?

So I have switched to the developer mode while developing on a Magento 2 project using the following command: php bin/magento deploy:mode:set developer All good, I got this message and I developed ...
32
votes
3answers
7k views

Magento 2: Plugin before/around/after Interaction

In Magento 2, when you create an "around" plugin public function aroundRenderResult( \Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response ) { ...
32
votes
2answers
3k views

Magento 2 - Why is Magento\Checkout\Model\Cart deprecated?

Since Magento 2.1, Cart has a @deprecated tag. Nevertheless, it is still used by Magento itself to store products when shopping. Is the deprecation intended, and if so, and what should we use instead?
31
votes
4answers
12k views

Magento 2: Is there a Profiler?

Does Magento 2 have a profiler? The Stores -> Settings -> Configuration -> Developer -> Debug panel still exists, but there's no settings for a profiler there. If Magento 2 does have a ...
30
votes
14answers
66k views

magento 2 admin url not working and loaded frontend is all messy

Admin url is showing 404 error after installing magento 2 on wamp server and frontend design is all messy and css is not linked to it.Error visuals are shown below. Frontend error:
30
votes
4answers
10k views

Magento 2 xml validation

For a while Magento 2 had a way to validate (and autocomplete) any xml by using an XSD file. For examplemodule.xml looked like this: <?xml version="1.0"> <config xmlns:xsi="http://www.w3.org/...
30
votes
3answers
57k views

How to add a custom CSS file in Magento 2

Is there a way to create my own CSS file that loads last in the cascade? If so, how and where do I add my custom CSS file?
30
votes
5answers
30k views

Why Magento 2 is extremely slow?

I used Magento 1.9 and it was okay.It wasnt as fast as a simple joomla site but i had many customers with no problem. Now i wanted to upgrade my site to Magento 2,i bought a new host (same as i ...
29
votes
10answers
33k views

Adding a non-category link to the navigation links in magento 2

I'm not sure what I'm doing wrong here. The block which holds the category links in is referenced to as navigation.sections. I thought by directing the following arguments toward the container I would ...
29
votes
9answers
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 ...
29
votes
4answers
26k views

Magento2 -How to get data from system configuration [duplicate]

Fields added through the system.xml and default values populated with config.xml, how do we fetch the data in Magento2
29
votes
2answers
36k views

Magento2 : How to database schema upgrade

I am working on magento custom module, in module have Setup\InstallSchema.php file which is installed before. i have added some more database fields in InstallSchema.php so i want to update table ...
29
votes
2answers
7k views

Magento 2: template security: which method to use?

I'm aware Magento 2 has several methods available to secure the template: $block->escapeHtml() $block->escapeQuote() $block->escapeUrl() $block->escapeXssInUrl() But I'm wondering when ...
29
votes
2answers
14k views

In Magento2 what is <script type=“text/x-magento-init”>?

I am new to Magento2 and our organisation has just get the EE licence. I have installed it on my local machine and the default template spits out the following mixed in with HMTL: <script type="...
29
votes
1answer
4k views

Magento 2 - Theme Type 0:physical, 1:virtual, 2:staging. When to use?

In the theme table there is a type field with 3 possible values: physical, virtual and staging. When to use physical virtual and staging theme? When I extended luma theme my new theme appear in ...
28
votes
4answers
43k views

Magento 2 - There are no commands defined in the “setup” namespace on windows [duplicate]

I have problem when I run this command: php bin/magento setup:upgrade Display error: [InvalidArgumentException] There are no commands defined in the "setup" namespace. I found some answers ...
28
votes
3answers
8k views

what is mview in magento2?

First of all what i know : Index management is useful for increasing store performance. EAV has one disadvantage.it will store data into different tables.so that retrieving data is time consuming. ...
28
votes
4answers
42k views

Magento 2 - Remove and change footer links

I want to remove the default links of the luma layout and add new links. How can I do that?
28
votes
19answers
8k views

Security Patch SUPEE-11155 - Possible issues?

Magento has released a new security patch for M1, and updates for M1 and M2. What common issues do you have to watch out for when applying this patch/upgrade? Magento 1 https://magento.com/security/...
28
votes
9answers
44k views

How to change the Admin session time in Magento?

It is possible that sometimes the time that the admin session is active is too short. How to change the time it takes to auto-logoff the user from the back-end?
28
votes
6answers
7k views

Magento 2 - Uninstallable set of packages when deploying magento-sample-data

I've followed this Magento DevDocs tutorial to install sample data after installing Magento 2. But after executing the last command ./bin/magento sampledata:deploy I get the following error: ./...
28
votes
3answers
11k views

Magento 2 - How to add captcha to a custom form

I'm developing a custom module which contains a form submission. I would like to add a captcha to it. And we want to use the Magento default captcha library so that the captcha is consistent with the ...
28
votes
2answers
2k views

How does Magento2 generate the specific ExtensionFactory and ExtensionAttributeInterface?

I would like to wrap my head around using extension attributes, for example for quote items. It is no problem adding a custom attribute to such an entity using a setup class like in Magento 1, this ...
28
votes
6answers
18k views

Clear Theme/CSS Cache in Magento 2

When I am theming a Magento 2 store, what is the suggested way to clean the caches? I edit the .less files and then I currently do rm -rf pub/static/frontend/* var/view_preprocessed/ var/*cache/* ...
27
votes
11answers
31k views

Magento 2 - What is the correct way to change default Order Id?

Magento 2. After fresh install the new Order id will be 100000001, 100000002 and so on. What is the correct way to change that increment id so it would be a higher number? For example 155555552, ...
27
votes
7answers
48k 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\...
27
votes
3answers
45k views

Error after magento upgrade

After firing this command in CLI php bin/magento setup:upgrade I am getting below error -: Fatal error: Uncaught exception 'Magento\Framework\Exception\LocalizedException' with message 'Can't ...
27
votes
4answers
18k views

Theming for Magento 2 - Starting from scratch

Some of you probably read that topic regarding theming from scratch for Magento 1: Theming - starting from scratch I was wondering, what would be the best practice to develop a theme from scratch for ...
27
votes
15answers
40k views

Refused to apply style “because its MIME type ('text/html') is not a supported stylesheet MIME type”

Suddenly CSS is not loading on my Magento 2 admin panel. The frontend is working fine. Error details: "Refused to apply style from 'https://www.ornativa.com/pub/static/version1502029409/adminhtml/...
27
votes
2answers
6k views

Magento 2: Plugin vs Observer

In Magento 2, what are the pros and cons of using a plugin vs an observer to achieve something? I understand that observers are subscribed to events whereas plugins can jump in before and/or after a ...
27
votes
3answers
4k views

Creating Integration Tests for Magento 2 Modules

So far for my Magento 2 testing needs, I've been using PHP Unit as (more or less) an acceptance tester -- testing results of server and HTML requests made into a system with my module(s) installed. I'...
27
votes
2answers
3k views

Magento 2 Templates: Use `$block` or `$this`?

In Magento 2, the $this variable no longer refereces to a template's block object. It refers to a template class Magento\Framework\View\TemplateEngine\Php However, this template class has a ...
27
votes
4answers
2k views

How to create a Marketplace ready Magento 2 extension

I have created a Magento 2 extension which I wanted to upload on Magento Marketplace. When I tried to upload my extension it got rejected multiple times with one or the other reason. Due to this and ...
27
votes
7answers
10k views

Certified Professional Developer Exam reading material

Recently Magento announced Certified Professional Developer exam for Magento2. After reading in this page https://u.Magento.com/magento-2-certified-professional-developer I have some questions ...
27
votes
1answer
4k views

Magento 2.1: using the entity manager

From 2.1 Magento has introduced Magento/Framework/Model/EntityManager I may be wrong here but from my understanding it is to replace Magento/Framework/Model/AbstractModel which was implementing the ...
26
votes
15answers
34k views

Magento 2 admin this webpage has a redirect loop

Magento 2 just released last night and I can't wait to work on it. I tried installing it with all prerequisites. Frontend works fine but when I tried to open backend it says "this webpage has a ...
26
votes
2answers
15k views

Magento 2: available field types in system.xml

What are available values for field types in etc/system.xml configuration file: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
26
votes
2answers
44k views

How to use jquery library in Magento 2?

I am creating a Magento theme where I need to include jQuery. When I add this <link src="js/jquery-1.7.1.js"/> in head. It is working but Magento javascript functions are not working. How to ...