Page 5 - Monthly Archives: 2019
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
If your Magento 2 Blog 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>
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.json
app/code/Magefan/Community/etc/module.xml
vendor/magefan/module-community/composer.json
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.
To solve the wrong IP address issue you need to:
1. Create a new file in M2 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-client-ip" xsi:type="string">HTTP_X_REAL_IP</item>
<item name="x-cf-connecting-ip" xsi:type="string">HTTP_CF_CONNECTING_IP</item>
<!-- <item name="x-cf-mfcustom-ip" xsi:type="string">SOME_CUSTOM_SERVER_KEY</item> -->
</argument>
</arguments>
</type>
</config>
3. Save the file,
Configuring Image Lazy Load is one of the great tips for Magento 2 image optimization 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 Magento 2 Image Lazy Load Extension 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
If you are going to participate in the Meet Magento NL conference what will take place in Louwman Museum, The Hague (Netherlands) on April 18, 2019, it's a great chance to stay connected. MAGEFAN team member, CEO Ihor Vansach will be at the conference. You will be able to get live communication, put questions about Magento Extensions and Magento 2 Services provided by Magefan, to talk about partnership and cooperation.
To get a resized post image in Magento 2 Blog 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); ?>
Sitemap is one of the most important things when it comes to website indexing and crawling. The same is true for your Magento 2 blog sitemap. If you want your content to be discovered by the search robots, you need to configure the blog sitemap.
So, today you'll learn everything you need to know about the sitemap in Magento 2 Blog to ensure proper content indexing.
Configure Magento 2 Blog Sitemap
Once you install the Magento 2 Blog Extension, the blog XML sitemap is generated automatically together with the regular Magento XML sitemap. You don't have to do anything.
Note: in all blog versions before 2.11.0, a separate blog sitemap is generated. It is available via the same path as your Magento sitemap, but with the blog_ or pub/blog_ suffix, like in the https://domain.com/blog_sitemap.xml.
Configure Frequency and Priority of Indexing
If you use Blog Plus or Blog Extra editions of the Blog extension you can change the priority and frequency of the blog items indexing in the
The sortOrder property for plugins in Magento 2 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.
Once you have configured OG tags on our website you may want to test it. In order to validate Open Graph tags please take the following steps:
1. Visit official Facebook Sharing Debugger.
2. Enter the URL of the page you want to validate in a corresponding field.
3. Press the Debug button. Example:
Loading JS files is critical for page rendering. However, in a lot of cases, it causes speed issues and leads to low Google PageSpeed Insights stores. That's why you need to make sure to defer JavaScript in Magento and optimize it properly.
While you can spend lots of time optimizing the code, it's not worth it. Especially when tools like
are there to help.So, today we'll go through the process of deferring JS in Magento step by step. You'll basically need to enable a few options and let the module do the rest.
Ready to start?
But before we do, navigate to Stores > Configuration > Magefan Extensions > Rocket JavaScript and enable it.
Step 1: Minify and Merge JS Files
Here you need to choose whether to Minify and Merge JavaScript Files. Both options improve JS loading and optimize JS files in general.
- Minification — the process of removing unnecessary data (blank lines, commend, delimiter, etc.) from JS files. This makes browsers to read them faster and return
If for some reason you need to copy Magento 2 Blog data 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 one that uses DB1. If not please upldate 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.