We’re rewarding the question askers & reputations are being recalculated! Read more.

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
26
votes
5answers
20k views

Instantiating Helpers in Magento 2

The latest builds of Magento 2 have done away with the Mage class. This mean we've lost the Mage::helper method. Is there a replacement technique (helper factory?) for instantiating helpers in ...
25
votes
5answers
40k views

How to get stock quantity of each product in Magento 2

How to get stock quantity of each product in list.phtml in Magento 2 ?
25
votes
19answers
69k 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. ...
25
votes
3answers
42k views

How can I change the default product images sizes on Magento 2?

In magento 1.x.x, we could change default thumbnail images in admin : System > Configuration > Catalog But in magento 2.0, how can I change theses value I can not seem to find any configs to allow ...
25
votes
3answers
7k views

How to fix warnings / errors raised by the Magento Marketplace technical review report?

With the new Magento Marketplace, a submitted extension goes through several validation states in order to be approved and available via the Marketplace. One of them is the technical review, from ...
24
votes
1answer
90k 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\...
24
votes
6answers
33k views

Magento2 Setup version for module is not specified

I installed a local copy of Magento 2. I am facing some problem with custom module. I followed following file/folder structure app/code/Ps/HelloWorld/etc/module.xml: <config xmlns:xsi="http://...
24
votes
17answers
7k views

Security Patch SUPEE-11086 - Possible issues?

Magento has released a new security patch for M1, and updates for M1 and M2. These releases include critical security fixes. "We strongly recommend that all merchants upgrade as soon as possible." ...
24
votes
2answers
20k views

Magento 2: Default Values for `system.xml` Configuration

In Magento 1, it was possible to Configuration a user interface for the System Configuration section in etc/system.xml files Set default values for those fields in the etc/config.xml files Behind ...
24
votes
5answers
13k views

Magento 2: Programmatically Add a Value to `core_config_data`

Does Magento 2 have a high level abstraction that allows end-user-programmers to update configuration values in the core_config_data table? Or is using straight SQL the only way to do this in Magento ...
24
votes
4answers
2k views

what would be the official date of Magento 1 sunset?

Now we are in progress of Magento 2 upgrade. Some sources I read that early 2018 Magento 1 support will be closed. If we get the Magento 1 official close date, we can decide our due date of upgrade. ...
24
votes
2answers
20k views

Filtering a Magento 2 Object Repository

In Magento 2, can you use a product repository to filter by product attributes? In Magento 2, you can use a search criteria object \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria, ...
24
votes
3answers
25k views

Why and when to use “ Flat Catalog”?

While doing bit research for speed issue of magento website i got some links where people says enable "Flat Catalog" to increase performance and speed . Issue is that why it is not enabled by default ...
24
votes
2answers
13k 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/...
24
votes
4answers
10k views

Display an image in the admin grid in magento 2

I want to display an image in the admin grid of one of my modules. I'm using the new grid system, the one with ui components. I took a look at how the thumbnail is added in the grid for products, but ...
24
votes
4answers
4k views

Which compilation commands are needed in developer mode and when?

Can somebody give me instructions when to run which compilation commands in Magento 2 developer mode? I'm not sure if I understand it right yet. In the devdocs, developer mode is described as follows:...
24
votes
3answers
4k views

Is there ever a reason to prefer $model->load() over service contracts?

I understand that the preferred way to work in between modules in Magento 2 is using the service contracts. So if I want to load a product, I use the product repository: $product = $...
24
votes
4answers
17k views

Magento 2 - Create order using REST API

I need to use the Magento REST API to create an order from a mobile client. In my case, mobile side will implement the payment directly using PayPal SDK. What I need to do is to create an order by ...
24
votes
4answers
10k views

Magento 2: Sending Email Programmatically

Does Magento 2 have any built-in integration with third party transaction email deliverability systems like Amazon SES, Mandrill, etc., or is the built-in email functionality still based around PHP's ...
24
votes
1answer
5k views

Magento 2: what are the Interceptors file in var/generation?

So I noticed some Interceptor.php files in var/generation I know that this folder contains generated classes created on the fly for the following: Factories Proxies Plugins I assume that ...
24
votes
10answers
24k views

Merged JS and CSS do not work when Production mode

I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js. Also the product page only ...
24
votes
1answer
768 views

Are collections history in Magento 2?

I know that a lot of code that is currently in Magento 2 (2.1.2) is more or less ported from Magento 1 and that a lot of code will be substituted by an equivalent in the future. In this aspect, I'm ...
23
votes
11answers
26k views

How to disable Magento 2 reviews

I'm trying to disable the Magento 2 product reviews feature. I tried Disabling the Module at the Magento 2 admin Stores\Advanced\Advanced\Magento_Review but the reviews tab on each product is still ...
23
votes
9answers
35k 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 ...
23
votes
11answers
16k views

How to get Magento version in Magento2 ? (Equivalent of Mage::getVersion())

How do I get the Magento version in Magento2.x (e.g. 2.0.0) ? In Magento1.x, I could do it with Mage::getVersion() So what's the equivalent in Magento2.x ?
23
votes
4answers
44k views

Magento 2 - How to get all items in cart?

At checkout page (chekout/cart) I want to edit the checkout button url destination based on cart items (link.phtml). How can I get all items in cart? I want to do this without using the API. Thanks.
23
votes
5answers
27k views

Magento 2: How to get controller, module, action and router name?

Magento 2: How to get controller, module, action and router name?
23
votes
13answers
30k views

Getting full image URL of product in template

I'm trying to create a static block for showing dynamic products. This is code that is supposed to get every child category and print the image for each product in each category. <?php $...
23
votes
4answers
31k 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'), ] ...
23
votes
2answers
1k views

Magento 2: what are the benefits of using UI grid components over the standard Grid.php?

So Magento 2 introduced the UI Components. One of them is the UI Component Grid (you can find more information about it here: Explanation of UI Component Grid in Magento 2) When creating a custom ...
23
votes
2answers
6k views

What is Context Object purpose in any class's constructor DI ? How Context works?

In most of the class's Constructors, a Context object is passed . I couldn't understand how this Context Obj works . I also noticed that sometimes this is passed to parent class's constructor like ...
23
votes
5answers
2k views

Running Magento 2 via FastCGI (not mod_php) on OS X via brew Packages

Based on various forum postings and conversations in the community, it seems like some folks are running Magento 2 development instances on OS X via a PHP environment that doesn't use the built-in ...
23
votes
4answers
11k views

Magento2 CLI module:enable gives error “Unkown module(s)”

In Magento2 I've built a simple custom module and want to enable it by CLI: bin/magento module:enable Vendorname_Modulename But it is giving me the following error: Unknown module(s): '...
23
votes
1answer
7k views

Magento2: what is the difference between referenceContainer and referenceBlock

Both referenceBlock and referenceContainer entities are used in layout in magento2. What is the main difference between them and how can I relate these entities to magento1.*.
23
votes
5answers
27k views

How to use messageManager to show an error after redirect

I have a Module which processes a Post action, and then redirects. Now there are error cases, and I would like to show messages for them to the users. I already know, that this code adds the message ...
23
votes
1answer
12k views

Magento 2: Adding Arbitrary HTML to the <head> of Every Page?

In Magento 2, is it possible to add an arbitrary bit of HTML to every frontend/cart page's <head/>? I know I can add a block to the content/<body> area with code something like this <...
23
votes
11answers
25k views

Magento2 running so slow on localhost development

I recently started developing on magento2 new extensions or customizations, and my first impression was a nightmare. I have to wait about 20-30s for every change I make? really? I'm talking about ...
23
votes
2answers
1k views

What is the proper way for unit testing PHP7 code with PHPUnit 4.1 in Magento 2?

When I'm writing my modules, I'm trying to supply them with unit-tests for the most critical parts of the application. However, there are at the moment (Magento 2.1.3) several ways on how to write ...
22
votes
8answers
33k views

Magento 2 Get Current Store Date Time

In Magento 1.x you could get the store date time via Mage::getModel('core/date')->gmtDate(); What would be the equivalent to this in Magento 2.x?
22
votes
4answers
32k views

Programmatically create a simple product in magento 2

I'd like to create simple product programmatically in magento 2. Is there any way to create ?
22
votes
7answers
3k views

Can anyone suggest more technical resources for Magento 2?

I was able to find few articles on Magento 2 from http://magenticians.com/ http://www.thienphucvx.com/ If anybody know some other resources can you please share it here? (links, Ebooks, blogs etc)
22
votes
10answers
34k views

How to delete and regenerate URL rewrites in Magento 2?

I have recently created 2 additional store view on magento 2 store. Now the url of category and Products are not for those stores is not proper Eg: http://example.com/catalog/category/view/s/pouches/...
22
votes
2answers
16k views

Magento 2: get the current currency code

In Magento 1, you could retrieve the current currency code by doing: Mage::app()->getStore()->getCurrentCurrencyCode() I'm wondering what is the recommended way of doing it in Magento 2. In my ...
22
votes
2answers
4k views

what does “displayArea” and “provider” of checkout_index_index.xml mean in magento2

what does displayArea and provider of checkout_index_index.xml mean in magento2?
22
votes
2answers
536 views

Is Magento Claiming Ownership of All Magento Markplace Extensions?

The customer agreement for Magento Marketplace (the new replacement for Magento Connect) contains the following You acknowledge and agree that Magento or its licensors own all legal right, title ...
22
votes
2answers
4k views

Magento 2: Where do Third Party Modules Go?

I just installed the first official release of Magento 2. I was surprised to find that the app/code folder was gone app/code This was for both the version downloaded from the website and the ...
22
votes
3answers
6k views

Missing CSS and JS files In magento2 Git Repository

I have Successfully Install the Magento2 But when I try to run Homepage I getting below Errors in the console. Then I have checked in Magento git Ripo https://github.com/magento/magento2/tree/master/...
22
votes
1answer
3k views

How can I have a custom XML file in modules merged as one in Magento 2? (MageStackDay mystery question 2)

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/inspired by Magento ...
22
votes
4answers
3k views

Extending the complexType named “imageType” with a custom image type

The goal of a module I'm currently developing is to add a custom image type called "opengraph_image". I added a new EAV attribute though my InstallData.php script which works fine. When I now login ...
21
votes
4answers
25k views

How to convert number into currency format in magento2

I want to convert number into currency format in magento2 like we do in Magento 1.x with this $_coreHelper = $this->helper('core'); $_coreHelper->currency(number_format(50,2),true,false) How ...