Page 4 - Ihor Vansach
- 1 min read
Today (Feb 12, 2020) we have been notified about a potential security issue in our thanks to Daniel Sloof's tweet.
Reviewing the code and communicating with Derrick Heesbeen, Lewis Voncken from experius.nl there was found the security issue.
Note that, no confirmed attacks related to this issue have occurred to date, however, malicious actors potentially were able to login to a customer account in a tiny timeframe after the admin user pressed the "Login As a Customer" button in the admin panel and before admin user was redirected to the storefront and actually logged in.
Timing is really important to reproduce this issue. The security issue may occur on all Login as Customer versions until v2.2.3 during just a few seconds after the pressing of the "Login As a Customer" button.
We encourage everyone who uses Login As Customer extension v2.0.0 - v2.2.2 to update the extension at least to v2.2.3 or apply this quick fix.
At Magefan we always pay attentionihor
- 3 min read
Modules in the Magento 2 file structure
Module files in Magento 2 are located in 2 directories.
1. app/code/<VendorName>/<ModuleName>/
2. vendor/<vendor-name>/<module-name>/
Vendor Name — is the name of the company/person that developed the module. In some cases, the name of the vendor may coincide with the name of the customer's company. Therefore, before developing a new module, the name should be agreed upon. In the examples, we use our name — Magefan.
Module files developed on order or modules from other companies installed via FTP are located in the app/code folder.
The vendor folder contains root modules, as well as modules installed using the Web Setup Wizard or Composer. You will find the Magento root modules in the vendor/magento folder.
Interesting to know:In the Magento 2 repository (dev branch) on GitHub (https://github.com/magento/magento2), all root modules are in the app code/Magento folder. And all PHP libraries are in lib/internal/Magento.
Thisihor
- 2 min read
To work with phpMyAdmin you need to have the webserver configured. If it is not installed use .
In this article, we will describe 2 phpMyAdmin installation methods:
1. Download phpMyAdmin from the official website.
It is suitable for everyone, regardless of the operating system. To get started, go to the downloads section of phpmyadmin.net and download the archive with the latest available version of phpMyAdmin to your computer.
Once you have finished, place the archive folder in your web directory. For convenience, rename it to "phpMyAdmin".
If you use a local web server, use these links http://localhost/phpMyAdmin or http://127.0.0.1/phpMyAdmin to access phpMyAdmin.
2. Installation from the Ubuntu repository
The second method is useful only for OC Ubuntu users. To install phpMyAdmin:
1. Update the available package data. Run the command:
sudo apt update
2. Install phpMyAdmin. Run the command:
sudo apt install phpmyadmin
During installation, the system prompts you to set which web serverihor
- 3 min read
If you want to set up a web server and look for some tips, this article is for you. Here are instructions for setting up a web server (LAMP = Linux + Apache + MySql + PHP) on OS Ubuntu 20.04, in connection with:
Apache 2PHP 8Mysql Sever 8
To start, go to the CLI (command-line user interface). You can open it with Ctrl + Alt + T combination. If you don't want to set up a local webserver, then you need to connect to your server via SSH.
Once you are on a proper instance in the terminal enter super user mode (root or sudo user). Run the following command:
sudo su
and enter the password to your account, if required.
Take the following steps to install the web server:
1. Update the available package information. Run this command:
sudo apt update
* In the examples, the commands that must be executed by the superuser beginning with the word sudo. You do not have to use sudo while in superuser mode.
2. Install the Apache 2 webserver.
sudo apt install apache2 gedit
3. Install the MySQL databaseihor
- 2 min read
Do you hate to see when your Magento 2 store is broken or is in maintenance mode while running Magento 2 deployment commands? Yes? That's great. In the next 5 minutes, we'll help you with this pain. At Magefan we've created a Linux bash script that allows you to run bin/magento setup commands without braking store, long downtime, and losing sales.
Attention! We do not provide support for this script, that is why we recommend to use .
To use Magento 2 zero downtime deployment please follow the steps bellow:
1. Install Magento 2 zero-downtime deployment script
Run these CLI commands in the Magento root directory:
wget https://raw.githubusercontent.com/magefan/magento2-zero-downtime-deploy/refs/heads/master/installation.sh -O zdd_installation.shsh zdd_installation.sh
2. Configure zero-downtime script
If you use specific static-content deploy commands then edit the file
deploy/app/static-content-deploy.sh
Edit deploy/app/env.php and add theseihor
- 2 min read
Some may be no longer in use in your store. Reasons for that can vary. Some modules become irrelevant over time or there may be some crucial functionality lacking. That's why you might want to uninstall an extension.
There are two methods for removing modules in Magento. You can either uninstall an extension manually or via composer. Let's have a look at each of them in more detail.
Uninstall Extension in Magento via Composer
To uninstall Magento 2 module located in the vendor/vendor-name/module-name folder:
1. Connect to the root folder of your Magento via SSH.
2. Find the extension you want to remove using the following command:
php bin/magento module:status
3. Disable the extension:
php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-contentphp bin/magento setup:upgrade
4. Go to your composer.json file to find the composer name of the extension and then uninstall it:
composer remove vendor-name/module-name
5. Run setup CLI commands:
php bin/magentoihor
- 2 min read
When a visitor scrolls the web-page down It is convenient to display a button that will allow easily, by a one-click move customer back to the top of the page.
(button example)
To enable such a button on your website please follow these simple steps:
1. Create default.xml layout file in your theme directory:
/app/design/frontend/ThemeVendor/ThemeName/Magento_Theme/layout/default.xml
2. Paste the XML code:
<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="before.body.end"> <block name="magefan.go.to.top" template="Magento_Theme::gototop.phtml" /> </referenceContainer> </body></page>
3. Create gototop.phtml template file:
/app/design/frontend/ThemeVendor/ThemeName/Magento_Theme/templates/gototop.phtml
4. Paste the code:
<style type="text/css"> #mfbacktop { background: #324367; border: 2px solid white; border-radius:ihor
- 1 min read
If your search does not work, most likely the issue is in your theme that overrides original blog templates and layout files.
Try the next steps:
1. Make sure that you have the latest Magento 2 Blog module version.
2. Try temporary remove Blog layout XML files and template PHTML files from your theme one by one and run static content deploy. Once find the file that brings the issue, pay attention to it.
3. Check if a blog search button in the sidebar has the attribute "disabled", if yes then it is disabled (not active), and this may be a root of the issue. In this case, find a code which makes it disabled. The disabled attribute can be added directly via .phtml file in your theme or with some JavaScript. If you cannot find it, then you can insert this JS script to undisable the button:
<script>require(['jquery', 'domReady!'], function($) { setInterval(function(){ $('#blog_search_mini_form .action.search').removeAttr('disabled'); }, 2000);});</script>
- 2 min read
The "Product Key is empty or invalid. The extension has been automatically disabled." issue appears because of three common reasons. Usually, it's because you use the outdated version of the Magefan_Communty module, you downloaded a free version of the module for Magento Commerce or you use Translation extension v2.2.9.
Let's see what you can do to fix this issue in different cases.
Solution for Magento Open Source (CE)
If you get this error while saving the Magefan extension on the Magento Community edition and don't see any Product Key field, as on the screenshot:
make sure that you have the latest version of the Magefan Community extension.
Note: Magefan Community is not a Magefan Blog or Magefan Login as Customer. It is a separate module that is used together with all Magefan extensions.
To check the version of the Magefan Community extension have a look inside one of these files:
app/code/Magefan/Community/composer.jsonapp/code/Magefan/Community/etc/module.xmlvendor/magefan/module-community/composer.jsonvendor/magefan/module-community/etc/module.xmlihor
- 1 min read
Sometimes, instead of the real customer IP address, you can see 127.0.0.1 or some other wrong customer IP in your Magento 2 Admin panel. It can be due to proxies, like Varnish, Cloudflare, Sucuri.net, that may be enabled for your Magento 2 store.
In this guide, we'll explore how to resolve this issue.
Note: If you use the Magento 2 Geo IP Database Extension by Magefan in version >2.3.5 and still encounter the wrong IP address issue, contact us for further investigation.
To solve the wrong IP address issue, you need to:
1. Create a new file in the Magento 2 directory:
app/etc/XIP/di.xml
2. Paste the code:
<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress"> <arguments> <argument name="alternativeHeaders" xsi:type="array"> <item name="x-cf-connecting-ip" xsi:type="string">HTTP_CF_CONNECTING_IP</item>ihor
- 2 min read
Configuring Image Lazy Load is one of the great that allows you to improve your website loading speed and reduce the page size by loading images gradually.
Once your images are lazy-loaded you are sure there won't be any delay in loading the page caused by images so that your customers receive the best user experience.
How to Configure Image Lazy Load in Magento 2?
First, you need to install the by Magefan. Then, navigate to Stores > Configuration > Magefan Extensions > Image Lazy Load and enable the extension. There are two options you can choose from. Let's talk more about both.
Lazy Load All Website Images
All you need to do to lazy load all website images is choose a corresponding option in the Blocks to Lazy Load select box. However, if you want to exclude some images from the lazy load, define them in the Lazy Load Blocks section and specify how many First Images from those blocks To Skip.
Lazy Load Selected Website Images
In case you want to lazy load only some specific imagesihor
- 1 min read
To get a resized post image in you can use this code in your template files:
<?php
$width = 100;
$height = 150;
$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
?>
<img
src="<?php echo $imageHelper->init($_post->getFeaturedImg())->resize($width, $height); ?>"
alt="<?php echo $block->escapeHtml($_post->getTitle()) ?>" />
If you don't want to use the height parameter then you can execute the resize function only with the first parameter, e.g.
<?php echo $imageHelper->init($_post->getFeaturedImg())->resize($width); ?>
Or if you use Magefan Blog version greater equal than v2.9.8, you can use this line (it will allow you to save the image width x height file proportion and not create a square image with white borders):
<?php echo $imageHelper->init($_post->getFeaturedImg())->resize($width, null, false); ?>
- 2 min read
The sortOrder property for determines when to call them (before, after, or around a method), on condition more than one plugin is configured for the same method.
<config>
<type name="{ObservedType}">
<plugin name="{pluginName}" type="{PluginClassName}" sortOrder="1" disabled="false" />
</type>
</config>
Prioritizing rules are as follows:
Before executing the original method, Magento will run before plugins from the smallest to the biggest value in sortOrder.
The part of the plugin around code will also be executed from the smallest to the biggest value before calling the original method (callable).
The after plugin is called from the biggest to the smallest after calling the original method.
Example:
Suppose there are three plugin classes (Plugin10, Plugin20, Plugin30). Each plugin class has before, after and around methods for the same method. sortOrder looks as follows for each of them:
Plugin10 - 10Plugin20 - 20Plugin30 - 30
The plugins and theihor
- 1 min read
If for some reason you need to copy from one database (DB1) to another (DB2) (in fact Import Blog data from one Magento installation to another), please follow these steps:
1. Make sure that Magento 2 instance that uses DB2 has the same blog extension version as the one that uses DB1. If not, please update the Magento 2 Blog module on one of them.
2. Create a backup of magefan_blog_* tables in DB2.
3. Remove all magefan_blog_* tables from DB2.
4. Make export (dump) of all magefan_blog_* tables from DB1
5. Import DB1 dump to DB2.
Using this instruction, you'll easily migrate ALL blog data from DB1 to DB2. For database manipulations, you can use phpMyAdmin, Adminer.
- 1 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
1. If you can find the extension files in the folder
app/code/Magefan/Blog
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-login-as-customer
then run composer CLI command to remove it
composer remove magefan/module-login-as-customer
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! This will clean all login as customer log and extension configurations.
1. Just in case please make a full backup (dump) of your Magento 2 database.
2. Run next MySQL queries to remove the dataihor
- 2 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
Removing files instruction depends on the way Blog extension has been installed in.
1. If you can find the extension files in the folder
app/code/Magefan/Blogapp/code/Magefan/BlogPlusapp/code/Magefan/BlogAuthorapp/code/Magefan/BlogAuthorapp/code/Magefan/BlogImport
then remove these folders.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-blog
then run composer CLI command to remove it
composer remove magefan/module-blog*
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deployphp bin/magento cache:flush
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! Thisihor
- 1 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
Removing files instruction depends on the way Auto Currency Switcher extension has been installed in.
1. If you can find the extension files in the folder
app/code/Magefan/AutoCurrencySwitcher
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-auto-currency-switcher
then run composer CLI command to remove it
composer remove magefan/module-auto-currency-switcher
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! This will clean all auto currency switcher configurations.
1. Justihor
- 1 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
Removing files instruction depends on the way Auto Language Switcher extension has been installed in.
1. If you can find the extension files in the folder
app/code/Magefan/AutoLanguageSwitcher
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-auto-language-switcher
then run composer CLI command to remove it
composer remove magefan/module-auto-language-switcher
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! This will clean all auto language switcher data.
1. Just in case pleaseihor
- 1 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
Removing files instruction depends on the way Facebook Open Graph extension has been installed in.
1. If you can find the extension files in the folder
app/code/Magefan/OgTags
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-og-tags
then run composer CLI command to remove it
composer remove magefan/module-og-tags
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! This will clean all open graph data.
1. Just in case please make a full backup (dump) of your Magento 2 databaseihor
- 1 min read
If you decided to remove , please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's extension.
Remove Extension Files
Removing files instruction depends on the way Convert Guest to Customer extension has been installed in.
1. If you can find the extension files in the folder
app/code/Magefan/GuestToCustomer
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-convert-guest-to-customer
then run composer CLI command to remove it
composer remove magefan/module-convert-guest-to-customer
Once extension files have been removed, run these Magento CLI commands:
php bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
Note: if you don't want your website to be down during deployment, try these .
Remove Extension Data (optional)
Attention! This will clean all convert guest to customer data.
1. Just inihor
- 2 min read
If you need to update by Magefan, please follow the steps below.
Note: the updating instructions depend on the method the Blog extension was installed with.
Attention! Before the update, we strongly recommend to create a backup of your Magento 2 files and database.
Update using composer
If the blog module was installed via the composer (check if vendor/magefan/module-blog folder exists), then you need to run these simple CLI commands in Magento 2 directory:
composer remove magefan/module-NAMEcomposer require magefan/module-NAME ^x.x.x# replace NAME with:# blog - for Basic plan# blog-plus - for Plus plan# blog-extra - for Extra plan# replace x.x.x with the version you want to usephp bin/magento setup:upgradephp bin/magento setup:di:compilephp bin/magento setup:static-content:deploy
If you want to upgrade to the Plus or Extra, check this guide on how to .
Update using archive and FTP
If the blog module was installed via FTP (check if app/code/Magefan/Blog folder exists), then followihor

