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
36
votes
7answers
49k 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
5answers
23k views

Get product attribute in cart in Magento2

I'm trying to grab a product attribute in the cart template. But I just does not work! The attribute is set to Visible on Catalog Pages on Storefront = yes and Used in Product Listing = yes I use a ...
11
votes
6answers
21k views

Magento 2.3 upgrade breaks HTTP POST requests to custom module endpoint

I have a custom module with a defined route as: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> <...
29
votes
7answers
25k 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/* ...
28
votes
3answers
11k 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 ...
25
votes
1answer
14k 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 <...
5
votes
4answers
18k views

import custom csv to custom table- magento 2

My requirement is import custom csv file to custom table. please share hints and key points to achieve this? Thanks.
21
votes
5answers
19k views

Add new tab in product edit page in admin Magento 2

I'm trying to create a custom module that will add a new tab on product edit page, right under Basic Settings. Can someone provide an answer?
13
votes
3answers
18k views

Layered navigation for custom collection on custom page - magento2

I am working on fetching layered navigation in magento2 for a custom product collection. I am getting custom collection already on the custom page need to show layered navigation. Tried to adapt this ...
3
votes
2answers
6k views

Magento 2: Save all product data outside Magento with Images

I have below code with Image Upload which is working fine. But images are not stored in Database Table as mentioned in Order. include('app/bootstrap.php'); use Magento\Framework\App\Bootstrap; $...
16
votes
4answers
14k views

How to show a custom attribute in the admin Shipping Address box?

I have added the drop-down custom field on the checkout page with custom values. It's working fine also save attribute values in the database but not display in the order shipping address. Any idea ...
9
votes
3answers
16k views

Magento2 - How to add a product into cart programatically when checkout_cart_product_add_after is fired

Consider there are two product ie: Product A and Product B. Product B is a virual product which i need to add to cart when Product A is added to it. To do so, I am trying to add Product B to cart by ...
8
votes
3answers
13k views

Magento 2 How to remove shipping method in checkout page

I want to remove shipping method from the cart page and checkout page. I am trying to remove the shipping method from checkout page but seems it's loading from the Knockout.js file. How can i remove ...
4
votes
6answers
20k views

how to display product image in sales/order/view/ page

I am trying to customize sales order view page and I want to show product image in order view page how can we achieve this. and the path of the file is vendor\magento\module-sales\view\frontend\...
19
votes
2answers
23k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
18
votes
2answers
20k views

How to add Cookie Magento 2?

I want to add a COOKIE with value and some duration, how to do it in magento 2. Thanks
11
votes
1answer
39k views

How to send an email programmatically in Magento 2? [duplicate]

How to send an email programmatically in Magento 2 instead of php mail() function?
11
votes
6answers
25k views

Magento 2: Set Custom product attribute value programmatically on product save

How to set a product's custom attribute on save? I have used the event/observer way but nothing works.
2
votes
2answers
2k views

How to fetch post method xml data in Magento2 controller

We have to implement the punchout concept in magento2. There is a 3rd party system they will send data using the cXML format to Magento 2 endpoint. We need to fetch that data in the Magento2 & ...
39
votes
8answers
5k views

What is Progressive Web Apps, or PWAs in Magento 2?

What does it mean that Magento is becoming a Progressive Web Application platform? What will be the code structure of PWAs in Magento? What is the deal with REST APIs and PWAs?
52
votes
3answers
9k 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.
25
votes
6answers
35k views

How to add/remove links on my account navigation magento2?

How to remove "Billing Agreements" and "My Wishlist" links from the navigation menu on customer account page?
25
votes
4answers
16k 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 ...
38
votes
5answers
90k 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 ...
12
votes
2answers
23k views

I want to customize my minicart in Magento 2. I need to add 3 attributes

I want to customize my minicart in Magento 2. I need to add 3 attributes: SKU, Manufacturer, and Manufacturer part number. These are existing attributes. I see where to add the output values but not ...
35
votes
1answer
8k 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 ...
15
votes
5answers
16k views

How to "add to cart" a product with custom input field and save it to Database?

I had created a custom module in which I am overriding the add to cart form on the product page, and I successfully did it with catalog_product_view.xml file. Now I can see a custom input field on the ...
12
votes
2answers
39k views

How to open popup when <a> tag onClick?

In Magento 2, I want to display a popup (with html code inside) when a user clicks on a link.
17
votes
1answer
28k views

how to add pagination on custom collection in Magento 2

I am working on custom module. How can i use default magento pagination with my custom collection and also set custom limits on that?
14
votes
3answers
17k views

Magento 2 How to create new order attribute programatically

I've been searching the web on how to create an order attribute (if thats whats called), essentially I just want a new database column to appear in the sales_order database, obviously I could create ...
13
votes
5answers
33k views

Magento 2: How to override mini-cart default template html file?

How to override /var/www/html/magento2/vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html file in our custom theme?
32
votes
3answers
64k 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 ...
21
votes
8answers
65k views

Magento 2 - How to get attribute options value of eav entity?

How can I get the attribute options values of eav entity? I found solution only for magento 1.x but M2 I don't know. M1: $attr = Mage::getResourceModel('eav/entity_attribute_collection')->...
15
votes
8answers
30k views

Refresh the cache programmatically in Magento 2 at window system

I am looking for code that can refresh or flush the Magento2 cache via script. It was so easy in Magento 1.x. I am running Magento2 on WAMP server (window).
11
votes
3answers
9k views

Add custom block on listing page : Magento2

I want to add my custom block on listing page[Magento-2] but without any modification on list.phtml or any .phtml file. Is there any possibility by using xml file ? Any help will be appreciated.
15
votes
5answers
24k views

Magento 2 Get order total on success page?

I'm trying to get the order total on the success page on magento 2 , I have added this code <?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); $totall = $...
13
votes
3answers
30k views

How to migrate Magento 2.0.x from one server to another?

We have a local environment for development. We need to do a migration from local to a Dev server for integration. Is there any detailed migration guide about how to migrate Magento from one server to ...
10
votes
3answers
18k views

Programmatically create a configurable product and assign the simple product to configurable product in Magento2 product

This is what I've done so far. The simple and configurable products are created. The problem is I cannot assign the simple product to configurable product. Here is the code (ids and attributes works ...
11
votes
8answers
22k views

Magento2: redirection from Observer

We have already know that How to redirect from an Observer for magento 1.x version. but for magento 2,we does not know How to forcefully do redirection from an observer. I have done google ,but does ...
10
votes
4answers
14k views

Magento 2: How to configure Nginx to use multiple websites with sub-folder

We would like to create multiple websites in Magento 2. There is an article about this topic in the Official Magento 2 Documentation, but the way they describe is not suitable for our case. They are ...
18
votes
2answers
8k views

how to reorder (switch) billing address before shipping address

on the onepage checkout I need to reorder the billing address before the shipping address. in fact the logic should be the other way around than it is now. if the shipping address differs from the ...
10
votes
2answers
7k views

Getting the product SKU in the header mini-cart

I want to be able to display the product SKU in the mini-cart of a Magento 2 site. But I'm not sure how to use KnockoutJS to pull in additional product information. The template that is being called ...
8
votes
8answers
21k views

How to check that customer is logged in on frontend in Magento 2.1?

How to check that customer is logged in? In authentication-popup.js I found following code: define([..., 'Magento_Customer/js/customer-data',...], function(..., customerData, ...) { ...
5
votes
2answers
18k views

Magento 2 : How to add custom data in order email

I am new to Magento. I want to override the new order email template and add custom details in the order email. Please help. Steps I have done 1. I have created a new email template and assign it to a ...
10
votes
4answers
9k views

Customer password not working after migration from Magento 1 to Magento 2

I have migrated only customers from Magento 1.6.2.0 to Magento 2.2.3 and customers migrated successfully and listed properly in the admin section. But when I try to login with the Magento 1 password ...
7
votes
2answers
24k views

how to send custom email no template in magento2?

In magento2 send email with contact module use: $transport = $this->_transportBuilder ->setTemplateIdentifier($this->scopeConfig->getValue(self::XML_PATH_EMAIL_TEMPLATE, $...
16
votes
5answers
9k views

What is the proper way of positioning/ordering CSS files in Magento 2?

In the Magento 2 DevDoc it says To include a CSS file, add the <css src="<path>/<file>" media="print|<option>"/> block in <head> section in a layout file. However it ...
2
votes
1answer
677 views

Dependent Custom option in Magento-2

How to create Custom option programatically in which both are drop-down and they are dependent on each other . Dependent in the sense , changing value of second drop-down option based on the value of ...
15
votes
3answers
17k views

How to add a CMS block programmatically in Magento 2?

I need to add a CMS block via an install/upgrade script. I've already figured out how to add "normal" CMS pages as seen in the script below. But since I can't find any way to add CMS blocks in Magento ...
2
votes
5answers
1k views

Magento 2 How to put a rule condition into the custom admin form using the ui component

Magento 2 custom extension how to put a rule condition into the custom admin form using the ui component with data base interaction. please refer the following rule condition image

1 2
3
4 5
98