54 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() /** *...
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 ...
user avatar
  • 2,038
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 ...
user avatar
17 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 ...
user avatar
  • 75.8k
14 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 ...
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 ...
user avatar
  • 502
12 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 ...
user avatar
  • 5,366
11 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 ...
user avatar
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 ...
user avatar
9 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 ...
user avatar
  • 3,764
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 `...
user avatar
9 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/...
user avatar
9 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. Create constructor /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute */ protected $_eavAttribute; /...
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&...
user avatar
  • 206
9 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 .....
user avatar
  • 21.7k
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 = $...
user avatar
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 ...
user avatar
8 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 ...
user avatar
  • 2,489
8 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 “...
user avatar
  • 5,876
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....
user avatar
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'); $...
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....
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::...
user avatar
6 votes

404 on Homepage magento 2.2.2

You can check DB table url_rewrite and found row cotains request_path='' (empty).It helped me in solving the problem.
user avatar
6 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 & ...
user avatar
  • 2,737
6 votes
Accepted

Magento 2 - How to add,save,display custom Field in Product Edit form using UiComponent?

I have resolved this issue by myself, below is the way i have resolved it. I have created Observer which calls after product save event. so below is the events.xml file below is the code : <?xml ...
user avatar
  • 9,610
6 votes
Accepted

The image content is not valid in magento 2.2.2

Try this $product->save(); instead of $productRepository->save($product);
user avatar
6 votes
Accepted

Magento 2 : Image Validation is not working in back end form

Try this. Use javascript to add the class. $fieldset->addField( 'banner_image_mobile', 'image', [ 'name' => 'banner_image_mobile', 'label' => __('...
user avatar
  • 5,876
6 votes

want to login customer via phone number in magento 2.2

As you want to logged in a customer with there default billing address telephone and its password. So, you have to create a custom module where you have check Your entered phone number exists ...
user avatar
  • 75.8k
6 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 ...
user avatar

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