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
28
votes
3answers
10k 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 ...
28
votes
7answers
24k 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/* ...
5
votes
3answers
16k 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.
24
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 <...
10
votes
5answers
18k 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"> <...
8
votes
1answer
13k views

What's the best event/way to listen for all order state changes in Magento 2?

I want to observe every order state change and react depending on the old and new status. What is the best way to accomplish this in Magento 2? It looks like there is the event ...
20
votes
5answers
17k 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
16k 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; $...
8
votes
3answers
15k 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 ...
19
votes
2answers
22k views

Magento 2: Product URL Suffix

How do I remove the .html suffix from the product pages?
17
votes
2answers
18k 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
10
votes
1answer
35k 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
5answers
20k 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
1k 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
8k 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.
37
votes
5answers
85k 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 ...
25
votes
4answers
14k 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
6answers
32k 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?
12
votes
2answers
20k 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 ...
17
votes
1answer
24k 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
16k 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 ...
11
votes
2answers
36k 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.
32
votes
3answers
59k 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 ...
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.
20
votes
8answers
57k 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')->...
14
votes
8answers
26k 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).
14
votes
3answers
21k 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 ...
13
votes
5answers
29k views

Magento 2: How to get resize image for Custom Module?

I'm using Magento 2 CE Version 2.1.0 I have Custom Module with Image Field. When it's uploaded, i want different size images as for product we have Thumbnail Image, List Image & Product Detail ...
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 ...
10
votes
4answers
12k 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
7k 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 ...
14
votes
4answers
12k 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 ...
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 ...
5
votes
2answers
15k 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 ...
8
votes
3answers
12k 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 ...
7
votes
2answers
22k 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, $...
25
votes
7answers
22k views

Admin config error: Undefined index: id in Iterator.php on line 59

Can someone please explain this error to me? Exception #0 (Exception): Notice: Undefined index: id in /home/staging/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 59 ...
12
votes
4answers
5k views

Magento 2 + Custom column added sku on grid not showing data in export file

I have added sku column on sales order grid using following steps, Package\Company\view\adminhtml\ui_component\sales_order_grid.xml <?xml version="1.0" encoding="UTF-8"?> <listing xmlns:...
4
votes
6answers
18k 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\...
2
votes
1answer
433 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 ...
0
votes
3answers
13k views

I want to add popup notify after adding products Magento 2

I wanted to Add notify popup form after adding the products but I couldn't get the file in magento 2. I need someone help who already done this work.
15
votes
3answers
15k 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 ...
11
votes
7answers
16k views

Why the error when creating a new product “Asymmetric transaction rollback.”?

When creating a new product and trying to save it, I get the following error message: Asymmetric transaction rollback error Has anyone else encountered this? Please share the fix :)
6
votes
1answer
3k views

Magento 2 - How to configure Grunt in PhpStorm

I'm trying to configure Grunt in PhpStorm. I have set for Grunt: Node interpreter: /usr/bin/node (exists) Package grunt-cli: [path to Magento 2 dir] I get the error bellow when I 'Reload tasks' in ...
5
votes
1answer
23k views

magento2 how to override model file? [duplicate]

I would like to override (call the below model file from my custom module called Demo_Customprice /vendor/magento/module-catalog/Model/Product/Option/Value.php How could we achieve this?
2
votes
2answers
4k views

Magento admin panel not loading properly no options for login

I setup fresh Magento 2.3 setup in my localhost. Frontend show properly but backend no options show login. Admin panel not loading properly. Screenshot below: I clear all caches but admin panel not ...
1
vote
1answer
261 views

Add new nation into nation's list in Magento 2.3.5

I want to add a new country Northern Ireland with the country code XI in Magento 2.3.5 Admin. any idea for this? I already tried with this - Add new country in default country dropdown in Magento 2.3....

1 2
3
4 5
96