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()
/**
*...
- 65.3k
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 ...
- 2,048
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 ...
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 ...
- 76.6k
17
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 ...
- 10.6k
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 ...
- 5,631
12
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 ...
- 3,874
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 ...
- 512
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 ...
- 2,289
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/...
- 15.5k
10
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;
/...
- 3,987
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
.....
- 22.2k
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 ...
- 261
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 ...
- 2,519
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 `...
- 5,113
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&...
- 206
9
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 “...
- 6,016
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 = $...
- 3,987
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 ...
- 491
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....
- 1,266
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-...
- 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 & ...
- 2,787
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');
$...
- 919
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....
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::...
- 561
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 ...
- 530
7
votes
Accepted
Magento 2 : Specific Range Validation in system configuration field
Add this code in your system.xml :
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
- 17.1k
7
votes
Which file hold this layout {{layout handle="sales_email_order_items" order=$order area="frontend"}}
You can update in the file :
vendor/magento/module-sales/view/frontend/templates/email/items.phtml
Or override in your custom module :
app\design\frontend\our-template\default\layout\sales.xml
app\...
7
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();
...
- 86
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.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
magento2.2.2 × 622magento2 × 183
magento2.2 × 39
magento-2.1 × 27
checkout × 22
database × 21
layout × 21
magento2.3 × 19
admin × 18
javascript × 18
product × 17
php × 15
module × 15
grid × 15
upgrade × 15
orders × 14
uicomponent × 14
rest-api × 14
product-attribute × 13
collection × 13
payment-methods × 13
configurable-product × 12
theme × 12
knockoutjs × 12
ui-form × 12