Hot answers tagged

189 votes
Accepted

Explanation of UI Component Grid in Magento 2

[EDIT 3 Oct 2018] Update for links to devdocs: 2.0 - https://devdocs.magento.com/guides/v2.0/ui-components/ui-listing-grid.html and https://devdocs.magento.com/guides/v2.0/ui-components/ui-secondary....
user avatar
  • 5,758
98 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 ...
user avatar
56 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
user avatar
38 votes

How to override an admin theme template?

You can declare a new primary theme for your admin area by customizing config (e.g. app/etc/local.xml) with the following: <config> <stores> <admin> <...
user avatar
  • 16.6k
38 votes
Accepted

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

Open your PHP Admin database (I tested on php 7) Find & click on the table called: sequence_order_1 (it is located in database itself not in the information_schema ) Click on "Operations" tab &...
user avatar
  • 963
38 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 ...
user avatar
34 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, ...
user avatar
32 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 ...
user avatar
30 votes
Accepted

Is Magento ready for PHP 7?

Magento announced officially on January 20th, 2016, that CE and EE 2.0.1 officially support PHP 7.0.2. Magento Enterprise Edition and Community Edition 2.0.1 are now available and feature ...
user avatar
  • 17.2k
30 votes
Accepted

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

not 100% sure about this, but I think you can add code to the head using this: <body> <referenceBlock name="head.additional"> <block class="Pulsestorm\Test\Block\Head" name=...
user avatar
  • 195k
30 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/...
user avatar
  • 301
28 votes
Accepted

programmatically adding product to cart returns empty price

There are many things wrong here and I feel compelled to do a code review with you. See the end for the correct approach. Code review: This line is loading a product with an undefined $sku var: $...
user avatar
  • 35.6k
27 votes

Is Magento ready for PHP 7?

If you are using the most recent version, M CE 1.9.2.2, there is an extension that will bring it to full PHP 7 compatibility: https://github.com/Inchoo/Inchoo_PHP7. (Disclaimer: I'm the author, though ...
user avatar
25 votes
Accepted

Magento 2: Programmatically Add a Value to `core_config_data`

There is the same saveConfig method: https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Config/Model/ResourceModel/Config.php#L26-L61 A usage example from the core: https://github.com/...
user avatar
25 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>"; ...
user avatar
  • 1,164
24 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 ...
user avatar
  • 1,666
24 votes
Accepted

Setting up an Admin Route in Magento 2

The difference is in urls. Url has following structure: <areaFrontName>/<moduleFrontName>/<actionPath>/<actionName> Route "Adminhtml" has moduleFrontName "admin", same as ...
user avatar
  • 4,446
22 votes

Is Magento ready for PHP 7?

No idea about PHP7, but I would guess most of the stuff is still valid in PHP7, you can find more information in the blog of Matthias Geniar ext/mysql: despite it being a very old MySQL ...
user avatar
21 votes
Accepted

Creating Integration Tests for Magento 2 Modules

This works for us but we haven't yet looked into moving them to a separate location to address 6.) 1.) Place your integration tests under dev/tests/integration/testsuite/Vendor 2.) copy dev/tests/...
user avatar
21 votes
Accepted

Magento 2: Run `setup:di:compile` **only** a Specific Module?

Short Answer: No. That is not possible with tools shipped with Magento now. Explanation: We have to distinguish code generation and compilation. Compiler does both. For both operations we need to ...
user avatar
  • 4,446
20 votes

Magento Redirects to Old Website regardless of what changes are made!

Or the oldest one in the book, your file/directory permissions are out of whack causing Magento to write to the system /tmp folder which means config information is cached till you reboot the whole ...
user avatar
  • 7,573
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(); $...
user avatar
  • 1,949
20 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 $...
user avatar
  • 5,244
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 ...
user avatar
  • 34.3k
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 ...
user avatar
  • 321
19 votes

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

What was previously in eav_entity_store is now covered in sales_sequence_profile and sales_sequence_meta. The table sequence_order_1 gets populated when orders are placed.
user avatar
18 votes
Accepted

Magento 2: Product Repositories, Filter Groups, and `AND`

Actual annotation of \Magento\Framework\Api\Search\FilterGroup says (class phpDoc): Groups two or more filters together using a logical OR It means that you need to create two groups with one ...
user avatar
18 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 ...
user avatar
  • 195k
18 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( ... \...
user avatar
  • 195k
17 votes
Accepted

Why do I get "SOAP-ERROR: Parsing WSDL: Couldn't find <definitions>"?

Apparently I fell prey to a common Magento pitfall, so I'm posting the answer in case anyone else is searching this particular error. Basically, the error was coming from the Magento installation I ...
user avatar

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