Magento2
Power your online business with the most flexible and scalable ecommerce platform
How Magento2 format the product URL
I have looked at almost 100 articles to know how Magento format the URL without any success and finally I found it and it was really so easy , here is the quick way to see it using object manager
Note: please consider to use the dependency injection
$_productloader = $objectManager->get('\Magento\Catalog\Model\ProductFactory'); $product = $_productloader->create()->load(1); echo $product->formatUrlKey({Your text here});
in this way Magento will give you the correct URL which will be used
How do you add translation for extensions in Magento2?
How do you add translation for extensions in Magento2?
Then generate the dictionary with magento shell tool; from :
php bin/magento i18n:collect-phrases -o app/code/{Vendor}/{Module}/i18n/en_US.csv app/code/{Vendor}/{Module}/
do not forget to replace {Vendor} and {Module} with your correct information
get all Observer in Magento2 for specific event
the easy way is to go to this file
\vendor\magento\framework\Event\Manager.php
then go to this function dispatch
you can now user this
foreach ($this->_eventConfig->getObservers($eventName) as $observerConfig) { if ($eventName == "catalog_product_save_after") { $all_observers = print_r($observerConfig, true); } }
Magento 2 correct permissions
The most frequent question, asked by Magento users, is correct permissions. They can differ, whether you run your store in one-user mode, or many-user, and also can be different for different modes.
Single user mode
One-user mode is the simplest case. In this case user shall belong to group, which own Magento system and also runs web-server. For them the following rules apply:
Apply Magento2 Patch manually using GIT
The best easy way is to simulate the directory path, so lets assume you will need to fix the comparison page after you upgrade to Magento 2.3.5-p2
Filename: vendor/magento/module-catalog/Helper/Output.php
we need to replace this line
- if (preg_match($pattern, $attributeHtml)) {
with this line
+ if (preg_match($pattern, (string) $attributeHtml)) {
Now create those directories vendor/magento/module-catalog/Helper
Magento - afterHasSpecialPrice plugin
To change the HasSpecialPrice value you need to create a new module then after that you can add this code to the etc/di.xml
Disable Coupon in Magento2 in the cart and in the checkout
The best approche is to add these files "checkout_cart_index.xml" and "checkout_index_index.xml" in this directory
app/design/frontend/{Vendor}/{theme}/Magento_Checkout/layout/
with this content
checkout_cart_index.xml
Magento2 Useful Plugins
- https://www.magezon.com/magezon-page-builder-for-magento-2.html : Build CMS Page, CMS Block, Product Description and Category Description
- https://www.magezon.com/magento-2-blog-extension.html : Empower Your Magento Blog and Grab More Audiences
Magento 2 static files are not working
How many times you tried to install Magento 2 and later you could not see the website working !!, How many times you tried to search for these sentences
"Magento 2 css not working"
"Magento 2 js not working"
"Magento 2 404 page not found" because of the static files?
Now here is the solution, and easily it is the missed .htaccess (for apache)
by quick look at this path "{magento root}/pub/static", you will see that you missed the .htaccess file
Magento 2 how to configure Nginx to allow execute phpinfo.php files in root folder
Go to the Nginx configuration then you need to edit the line similar to this line
location ~ (index|get|static|report|404|503)\.php$ {
to be like this
location ~ (index|get|static|report|404|503|phpinfo)\.php$ {
then restart Nginx