Skip to main content
101 votes
Accepted

Magento 2 Allowed Memory exhausted error when compile code

A quick solution for memory limit in Magento 2 command is directly adding memory limit inside command. For Compilation command, php -dmemory_limit=5G bin/magento setup:di:compile For Deployment ...
Rakesh Jesadiya's user avatar
68 votes
Accepted

Magento-2:Class Magento\Framework\App\Http\Interceptor does not exist

The Interceptor file is deleted. Need to recreate Interceptor Run di:compile command php bin/magento setup:di:compile
Arunprabakaran M's user avatar
41 votes
Accepted

Magento 2 : Add Product Attribute Programmatically

Overview of Adding Product Attribute Programmatically Step 1: Create file InstallData.php Step 2: Define the install() method Step 3: Create custom attribute Step 1: Create file InstallData.php ...
Prakash Patel's user avatar
40 votes
Accepted

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry - Magento 2

Entry key '4639-168-1-283-4639', where 4639 is product_id, 168 is attribute_id, 1 is store_id, 283 is attribute_value_id for which is getting this issue. So if suppose attribute 168 type is varchar, ...
dev_67Commerce's user avatar
33 votes

Magento 2 - What is the correct way to change default Order Id?

Go to your database from phpmyadmin, Here _1 is used for store id after tablename. Default Frontend store id is 1. if you have multi store then you have to set query for each store with table name ...
Rakesh Jesadiya's user avatar
31 votes

Magento 2: How to show address field in registration form?

Example display address fields using customer_account_create.xml: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/...
wit's user avatar
  • 311
29 votes
Accepted

Receive Post Parameters In Magento 2 Controller

To get Post data in controller you need to use following in your execute function. public function execute() { $post = $this->getRequest()->getPostValue(); echo "<pre>"; ...
Salma Saiyad's user avatar
  • 1,224
27 votes

Magento 2: Programmatically Add a Value to `core_config_data`

I wouldn't use a model or a resource model, but \Magento\Framework\App\Config\Storage\WriterInterface or \Magento\Framework\App\Config\ConfigResource\ConfigInterface (the first delegating to the ...
nevvermind's user avatar
  • 1,736
22 votes

Magento 2 - Get Subcategories of Specific Parent Category

Check below example to list of all subcategories of specific parent category using parent category ID using the repository. First of all add CategoryRepository in construct: <?php protected $...
Aasim Goriya's user avatar
  • 5,454
20 votes

Magento 2: Sending Email Programmatically

Magento 2 TransportBuilder uses a email templates to compose email's body. The simplest way I found to send plain text - use Zend_Mail (that is used by Magento 2 itself): $email = new \Zend_Mail(); $...
Alex Gusev's user avatar
  • 2,019
20 votes
Accepted

Admin Product View Page Error on Sort Magento 2.3

SKU should be empty or string. In your case, it is null or not a string. Run follwoing query will resolve your issue if it is null sku related error: UPDATE catalog_product_entity SET sku='' WHERE ...
Sohel Rana's user avatar
  • 35.9k
20 votes

Error when mass updating Attributes

A flaw in the migration script left the setting empty for: Stores -> Settings: Configuration -> Catalog -> Inventory -> Product Stock Options: Minimum Qty Allowed in Shopping Cart Change ...
siddiqui's user avatar
  • 321
19 votes
Accepted

Magento2 Creating a new directory

you can use \Magento\Framework\Filesystem\Io\File. Either inject an instance of it in your class or instantiate it manually using new. Then do this: /** @var \Magento\Framework\Filesystem\Io\File $io ...
Marius's user avatar
  • 198k
19 votes

Magento 2 - Get Subcategories of Specific Parent Category

You need to add a dependency to your class \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory. Like this: protected $categoryCollectionFactory; public function __construct( ... \...
Marius's user avatar
  • 198k
19 votes

Magento-2:Class Magento\Framework\App\Http\Interceptor does not exist

This occurs Because you can inject Magento\Framework\App\Http in any our class try following steps php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-...
Waqar Ali's user avatar
  • 2,349
17 votes

Magento 2: what is the $data array constructor parameter?

The $data[] can be used to hold values passed from di.xml's arguments replacement mechanism, when \Magento\Catalog\Block\Product\ListProduct intantiated. In your case this could be populated by <...
Codrain Technolabs Pvt Ltd's user avatar
17 votes
Accepted

How is magento 2 better than magento 1?

This question may be opinion based but I'm just going to enlight some results from the offical white paper regarding Magento 2 performance and scalability Test Configuration Magento Enterprise ...
Raphael at Digital Pianism's user avatar
17 votes
Accepted

Magento 2: What's the Difference Between the Two Grid Component Data Providers?

To me, that main difference is that the Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider uses the Search API. The following classes are used in this class : Magento\Framework\Api\...
Raphael at Digital Pianism's user avatar
17 votes
Accepted

How to delete unused images from my media folder?

You can use the Hackathon EAV cleaner module for this. After installation you can use the command eav:media:remove-unused You can find it on Github: https://github.com/magento-hackathon/EAVCleaner/...
Tjitse's user avatar
  • 1,310
17 votes
Accepted

Errors during compilation: AbstractConfigOption.php

Since approx. 2hrs there is a pull request for symfony/console. This will fix that issue. https://github.com/symfony/console/pull/75
Matthias Richter's user avatar
16 votes
Accepted

What is <update handle="customer_account"/>?

Each page on a Magento website has a handle. That handle equates to a layout XML file. For example, <update handle="customer_account"/> indicates to Magento’s layout system that it should take ...
Shawn Abramson's user avatar
15 votes

Magento 2 Allowed Memory exhausted error when compile code

use this 'dirty' way php -dmemory_limit=-1 bin/magento setup:di:compile
Ansyori's user avatar
  • 841
15 votes

Magento 2 - What is the correct way to change default Order Id?

Though all above answers are correct fully/partially, I thought to write down the answer as this would be helpful for future readers. This answer will address two questions: 1) How to change the ...
Dexter's user avatar
  • 3,613
15 votes

Magento 2 : print_r or var_dump is not working

This one is crazy with magento because sometimes it works and sometimes it just shows blank page. Once it gave me a real hard time. Finally found solution somewhere. $_product = $block->getProduct(...
shah dhairya's user avatar
15 votes
Accepted

CMS Page URL from ID in phtml (M2)

By using object manager you can get CMS page url, if you have already id of cms page. $pageId = 1; $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); or $this->...
Chirag Prajapati's user avatar
15 votes

Magento 2 : External link in admin order grid not linking when click

If You are using custom class for rendering column ( for example <column name="link" class="My\Module\Ui\Component\Listing\Column\Link">) which convert your column value to link html along with ...
Pavel  Sidorenko's user avatar
14 votes
Accepted

Magento 2: what is the $data array constructor parameter?

The $data can be used to populate data on your object since the constructor of \Magento\Framework\DataObject is this public function __construct(array $data = []) { $this->_data = $data; } or ...
Kristof at Fooman's user avatar
14 votes
Accepted

How to setup Magento 2 with Docker

I've been using for the last 6 months the docker images created by Fabrizio Balliano It works nicely on ubuntu. And you have a readme file explaining what you need to do to get it running.
Marius's user avatar
  • 198k
14 votes

Errors during compilation: AbstractConfigOption.php

I had the same problem tonight. I did a trace to find out which module is causing the problem. I had to downgrade symfony/console to get it to compile. composer require symfony/console=4.4.26 After ...
Chris Perver's user avatar
13 votes

Get page title in Magento 2

At magento every phtml file have block class.So you get page title by $block->getLayout()->getBlock('page.main.title')->getPageTitle()
Amit Bera's user avatar
  • 77.6k

Only top scored, non community-wiki answers of a minimum length are eligible