Skip to main content
57 votes

Magento 2: template security: which method to use?

The escaping methods in AbstractBlock all delegate calls to Magento\Framework\Escaper, so you'll find an overview there. Let's look at the public methods and their documentation: escapeHtml() /** *...
Fabian Schmengler's user avatar
24 votes
Accepted

500 Internal Server Error when installing magento2.2.2

Ok Finally.... here is the process i did follow to get rid from this. Step1:: Please make sure that LoadModule version_module modules/mod_version.so is loaded from httpd.conf file to resolve Invalid ...
Zahirabbas's user avatar
  • 2,083
20 votes

Magento 2: how to delete orders from the database

You can delete all the orders, order history, shipments, invoices, credit memos, also the quotes, quote items from database by following SQL: SET FOREIGN_KEY_CHECKS=0; # Clean order history TRUNCATE ...
Sukumar Gorai's user avatar
19 votes
Accepted

Magento 2.2.2 how to check if current page is a CMS page in .phtml file?

There are no registry variable add at cms page. So, if you want to check a page is CMS page then you need to check current controller and action name means Full action name Best practices In ...
Amit Bera's user avatar
  • 77.6k
18 votes
Accepted

Magento 2: template security: which method to use?

This is for Magento 2.0. For 2.1, refer to Fabian's answer escapeHtml Use this function in the case of a string output that should not contain HTML. Example: <span class='label'><?php ...
Raphael at Digital Pianism's user avatar
14 votes
Accepted

Magento 2 Please update innodb_buffer_pool_size or decrease batch size value

Magento can increase the memory for processing a large amount of data by using memory engines instead of InnoDB. The algorithm increases the memory value for the max_heap_table_size and tmp_table_size ...
Pratik Oza's user avatar
  • 3,992
13 votes
Accepted

Magento 2 Reindex Fail `Unknown column 'entity_value.value'` in 'field list'

I've found the problem: Table: catalog_product_super_attribute was inserted a row with attribute_id that didn't exist e.g I have size and colour in table eav_attribute I have size id=2 and colour ...
Juliano Vargas's user avatar
13 votes

Magento 2: how to delete orders from the database

I suggest you to avoid direct mess with SQL. You can use any good extension like Mageplaza Another option is to create a script on root and delete order programmatically You can create a file at ...
Pawan's user avatar
  • 5,906
12 votes
Accepted

How to get the attribute id by attribute code in magento 2

Get Attribute Id By Attribute Code In Magento2. Just you have to follow some steps. public function __construct( Context $context, private readonly \Magento\Eav\Model\ResourceModel\Entity\...
Nikunj Vadariya's user avatar
12 votes
Accepted

Error during compilation in magento 2.2.2

I had solved the error by replacing the $connection = null, with \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, within the constructor. Thank guys for those who are tried to ...
Ask Xah's user avatar
  • 532
10 votes
Accepted

How to add a new field in cart price rule form in magento 2 backend?

Create file in your custom module app/code/Vendor/Module/view/adminhtml/ui_component/sales_rule_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/...
Siarhey Uchukhlebau's user avatar
10 votes

Get database connection in magento 2

Use \Magento\Framework\App\ResourceConnection class to get resource connection protected $_resource; public function __construct( ... \Magento\Framework\App\ResourceConnection $resource .....
Prince Patel's user avatar
  • 22.8k
10 votes
Accepted

Get database connection in magento 2

Without a Mage class, how does a developer instantiate model or magento-singleton object? The Mage::getModel and Mage::getSingleton methods have been retired, and in their place Magento has a new “...
Chirag Patel's user avatar
  • 6,156
10 votes
Accepted

Magento 2 not minifying JS, CSS or HTML in Production Mode

After a lot of struggling with this, i've finally found the issue. I dived into the magento 2 source code to try and decipher how it decides when to minify files. I discovered that even though our ...
Jako Basson's user avatar
9 votes
Accepted

How to post data to a payment provider when placing an order in Magento 2

As @Yogesh said in the comment, it depends on payment gateway and it's API. I see at least few possible solutions with different variations and without API documentation for payment gateway, it would ...
joni jones's user avatar
  • 2,549
9 votes
Accepted

Magento 2 Admin Page Error: Your current session has been expired

Find path admin/security/session_lifetime in core_config_data table If it's present then set its value to 86400 If that path is not present then add it with value 86400 INSERT INTO `...
Mukesh Chapagain's user avatar
9 votes
Accepted

Magento 2 - Track order button not work

Ussually, this error happens because of carrier getTracking() function is not returning the proper value. You can fix this by modifying the shipping plugin's code located in app/code/<Plugin name&...
Nishad Up's user avatar
  • 206
9 votes

Get database connection in magento 2

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $connection = $...
Nikunj Vadariya's user avatar
9 votes
Accepted

Magento 2.2 - Uncaught TypeError: this.modal.zIndex is not a function

make the following change in _setActive function in modal.js _setActive: function () { var zIndex = this.modal.css("zIndex", ), baseIndex = zIndex + this._getVisibleCount(); ...
numid64's user avatar
  • 106
8 votes

Magento 2.2.2 .htaccess Internal Server Error

Make sure you have mod_version installed (see https://httpd.apache.org/docs/2.4/mod/mod_version.html ) If you cannot install mod_version on your server, you can revert this PR in your local .htaccess ...
Jonas Hünig's user avatar
8 votes

How to call phtml of custom module in my custome theme layout Magento2?

try this in your layout file (customhome.xml) <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration....
Bhakti Thakkar's user avatar
7 votes

Magento 2: template security: which method to use?

For Magento 2.4 you shoud in phtml template use $escaper->escapeHtml(...) instead of $block->escapeHtml(...). Full doc is available here: https://devdocs.magento.com/guides/v2.4/extension-dev-...
Jaro's user avatar
  • 313
7 votes

How to post data to a payment provider when placing an order in Magento 2

Here's my final solution to help others that are struggling with this: Part 1: Create a basic module/payment method (http://devdocs.magento.com/guides/v2.2/howdoi/checkout/checkout_payment.html & ...
Lez's user avatar
  • 2,917
7 votes

Magento 2.2.2 how to check if current page is a CMS page in .phtml file?

Try to use below code in your .phtml file <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $request = $objectManager->get('\Magento\Framework\App\Request\Http'); $...
Chander Shekhar's user avatar
7 votes

Magento2 unit tests doesn't run using vendor/bin/phpunit or vendor/phpunit/phpunit/phpunit

./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/VendorName/ModuleName/Test/Unit Try Below Command instead of yours ./vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml....
Gaurav Manwani's user avatar
7 votes

IN STOCK FILTER FOR Magento 2 Product collection

You can also try below code $pCollection = $this->getObjectManager()->create('Magento\Catalog\Model\ResourceModel\Product\Collection'); $pCollection->setStoreId($storeId); $...
Hardik Patel's user avatar
7 votes

What is the right way to get both, the admin translation and the frontend value of a multiselect attribute?

Assuming your attribute options are coming from a table, and I assume they are because you reference admin and store values, we should be able to call \Magento\Eav\Model\Entity\Attribute\Source\Table::...
Richard Klint's user avatar
7 votes
Accepted

Magento 2: How to reload Order Summary Section?

You can use 'Magento_Checkout/js/action/get-totals' to update the order summary . Please check this code define([ 'uiComponent', 'jquery', 'Magento_Checkout/js/action/get-totals', '...
Mac's user avatar
  • 573
7 votes

How to get the Quote Id from Masked Quote Id (QuoteIdMask) in magento 2

Since 2.3 version of Magento you can use the \Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface::execute(string $maskedQuoteId) to obtain a real quote id (int): <?php namespace Vendor\Module\...
Siarhey Uchukhlebau's user avatar
7 votes

Magento 2 Too many password reset requests even when password reset protection is disabled

I had similar issue but for me there was an option where I can set the minimum Time between password reset requests as shown below. In my case, it was set to 10 min. After I change it to 0 the issue ...
Sarjan Gautam's user avatar

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