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
158 votes
10 answers
176k 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 ...
78 votes
14 answers
249k 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 ...
  • 991
102 votes
12 answers
37k 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 //...
  • 197k
80 votes
21 answers
129k 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?
39 votes
24 answers
205k views

Magento 2 CSS and JavaScript not loading from correct folder

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 the site to load I am now faced with 404 ...
  • 393
45 votes
6 answers
48k 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 ...
  • 2,003
40 votes
9 answers
85k 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, ...
138 votes
21 answers
288k 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 ...
  • 44.1k
43 votes
18 answers
78k 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 ...
  • 709
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. ...
104 votes
5 answers
55k 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/...
  • 44.1k
54 votes
3 answers
28k 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 ...
34 votes
10 answers
32k 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 ...
  • 4,219
104 votes
6 answers
42k 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 ...
35 votes
4 answers
84k 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?
  • 1,011
30 votes
4 answers
20k 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 ...
24 votes
6 answers
12k 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 ...
8 votes
6 answers
42k 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 ...
  • 521
41 votes
3 answers
83k 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 ...
  • 1,080
7 votes
2 answers
5k views

How to set custom tax price during add to cart in Magento 2

I am adding product to cart using ajax call. Here is my controller code. use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\...
  • 1,819
29 votes
6 answers
61k 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 ...
8 votes
10 answers
8k 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?
  • 1,114
58 votes
4 answers
24k 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 ...
  • 197k
22 votes
5 answers
35k views

Magento 2: How to create a customer custom attribute? [duplicate]

What are steps to create a custom attribute for Customer entity in Magento 2?
  • 2,566
17 votes
3 answers
32k 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
88 votes
13 answers
199k 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 ...
  • 1,283
33 votes
15 answers
96k 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:
  • 523
16 votes
4 answers
23k 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/...
  • 649
20 votes
2 answers
22k 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 ...
  • 1,011
65 votes
4 answers
47k 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....
45 votes
8 answers
77k 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 ...
33 votes
12 answers
44k 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 ...
28 votes
6 answers
63k 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'), ] ...
  • 421
14 votes
2 answers
20k 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 ...
  • 15.5k
5 votes
3 answers
5k 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 ....
user avatar
84 votes
16 answers
123k 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 ...
  • 12.1k
26 votes
7 answers
64k views

Magento 2 How to add custom sort by option

I need to add an additional filter based on created_at attribute for sorting product list by latest product. I tried to figure it using below file app/design/frontend/Vendor/ThemeName/Magento_Catalog/...
24 votes
10 answers
40k views

How to update magento2 from 2.0.0 to 2.0.2

The docs here say that you should use the system upgrade utility: http://devdocs.magento.com/guides/v2.0/comp-mgr/upgrader/upgrade-start.html and do it from the admin. I thought that you would be ...
18 votes
5 answers
23k 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/...
  • 3,941
18 votes
7 answers
66k views

Magento 2.2.2 : Allowed memory size of 792723456 bytes exhausted (tried to allocate 184320 bytes)

I am working in magento 2.2.2 and when I save product It will display this error. Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to allocate 184320 bytes) in /var/www/html/...
  • 17.1k
17 votes
5 answers
25k 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 ...
13 votes
2 answers
17k views

Magento 2 : How to add a product grid in custom module using ui component?

I have added product grid in Magento 2 admin form using this link: product grid. But now I am creating admin form using ui component and I am not able to change product grid using ui component. Please ...
  • 990
61 votes
6 answers
64k 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"&...
  • 44.1k
45 votes
8 answers
82k 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 ...
  • 4,013
9 votes
1 answer
14k views

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

I have customBlock in product_view. How do disable cache for this?
  • 2,064
42 votes
3 answers
76k 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?
31 votes
1 answer
170k views

Magento2: How to load product by id [duplicate]

I got the product collection in my custom template using the following snippet: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\...
  • 2,112
23 votes
3 answers
21k views

Magento 2 - How to add the DateTime UI Component

I want to add new field as datetime in CMS page section while adding new page, I found that magento using UI Component for it, so after digging I could able to add the date field by using below code ...
11 votes
7 answers
48k 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, ...
  • 1,491
10 votes
6 answers
27k views

How to Add New Fields on Registration page?

How to add a new field for the registration page in Magento 2?
  • 3,253

1
2 3 4 5
102