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 ...
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 ...
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 //...
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?
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, ...
22
votes
14answers
93k views

Magento 2 CSS and JavaScript not loading from correct folder

I am hoping that someone on here can help. I am attempting to install and run Magento 2 on WAMP on a Windows 7 machine with little success. After jumping through the many and various hoops to get ...
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. ...
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/...
22
votes
4answers
16k 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 ...
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 ...
11
votes
6answers
3k views

Magento 2: When should I run which commands?

I have been working with Magento 2 for 2 months now. I realized that I am using bin/magento setup:upgrade way too much. I think I do not know when I have to run that command. Here are the situations ...
12
votes
2answers
18k views

Magento 2: How to create a customer custom attribute?

What are steps to create a custom attribute for Customer entity in Magento 2?
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 ...
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 ...
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 ...
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 ...
8
votes
7answers
6k views

How to create simple module in magento 2

I'm new to magento2. I want to create simple Hello World module in magento 2. How to create this module?
26
votes
10answers
27k 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 ...
15
votes
2answers
14k views

How to create a Child Theme in Magento 2

I want to modify certain aspects of the out-of-the-box Luma theme but I would like to do it by preserving the original file(s) and also ensuring that whenever I update Magento I preserve my changes as ...
16
votes
5answers
21k views

No images or JS on new Magento 2 installation

I've just installed Magento 2 onto my production server under a development. subdomain. The install appeared to have been successful but I've noticed there are no images or working javascript in both ...
24
votes
3answers
43k 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?
2
votes
3answers
2k views

How to change color of cart icon in minicart?

I am trying to change color of cart icon in header/minicart , as currently it's in grey shade I tried changing via adding following css in my custom.css at \web\css\custom.css .minicart-wrapper ....
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....
26
votes
14answers
54k 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:
13
votes
4answers
14k views

Create Multi Website/Stores in magento 2

Can you please provide the source/procedures to create a multi websites in magento 2. I have a google it regarding this,but none of the source/procedure didn't provide the path to create multi website/...
4
votes
6answers
16k views

How to create order programmatically in Magento 2?

I have special order form and now I need to create orders without payment. So the payment needs to be skipped. I am not sure what would be the best way to accomplish this part. Should I send my form ...
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 ...
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"&...
10
votes
2answers
8k views

How to use Knockout JS within Magento 2

My problem: I am attempting to write a small Knockout JS app within Magento 2, I'm struggling to initialise the app as when I use ko.applyBindings(AppViewModel, document.getElementById("koTest")); it ...
20
votes
1answer
7k 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 ...
20
votes
4answers
21k views

How to disable the cache for the block in Magento 2?

protected function _construct() { $this->addData( [ 'cache_lifetime' => false, 'cache_tags' => array('MY_BLOCK'), ] ...
9
votes
1answer
2k views

Magento 2 - enable cash on delivery only for specific shipment method

How to, for example, enable cash on delivery payment only when customer selected flat rate shipping method? I cannot find a way doing this in shipment/payment configuration or in cart rules.
9
votes
4answers
7k views

Override abstract class in Magento 2

In Magento 1 I could copy abstract class to local or community directory and Magento used it, when autoload load this class. Is there some solution to make to Magento loads my class instead vendor/...
27
votes
2answers
34k 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 ...
4
votes
2answers
6k views

How to Add Custom fields to Checkout page in Magento2

I need to add two custom fields in each shipping and payment steps of checkout page in Magento 2 and also data should be saved in needed tables how to do it in Magento 2
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....
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 ...
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 ...
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 ...
13
votes
4answers
19k views

Magento 2 How to Add a New Column to Orders Grid

I've added a new column to the table sales_order called export_status, now I want to add new order grid column with the data from the new sales_order column. I've managed to add column to the ...
14
votes
10answers
19k 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 ...
4
votes
3answers
18k views

Magento2 : Admin module Image upload code to display form

I have magento2 admin custom module with image upload functionality. I want to upload image from admin. what code should apply for display image field in from, upload image, also image display in edit ...
23
votes
19answers
60k views

CSS and Javascript files are not loading after Magento 2 installation

I've installed Magento 2 on local server successfully using composer but I'm not able to see frontend and admin panel designs. I see plain texts there. While looking at console I see following error. ...
16
votes
3answers
12k views

Magento 2: rewrite controller

how can i rewrite a controller (that's actually an action) in Magento 2? I tried, as instructed here like this: I have my own module called Namespace_Module with a di.xml file, that is taken into ...
9
votes
1answer
7k views

How do disable caching of custom block on product view page?

I have customBlock in product_view. How do disable cache for this?
8
votes
3answers
5k views

Magento 2 - Redirect user to a specific page if not logged in

I need to redirect user to a landing page if not logged in. I find a similar work in this link. Is there a solution for Magento 2?
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?
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/...
21
votes
2answers
10k views

Magento2 translating Javascript (KO) template text

I am trying to add a translation for the text <!-- ko i18n: 'Store credit available' --><!-- /ko --> present in vendor/magento/module-customer-balance/view/frontend/web/template/payment/...