Page 26 - Blog
News, insights and resources from the world of e-commerce
- 1 min read
If you face an unexpected 301 or 302 redirect in Magento 2 and you don't know why it happens or what code causes it, you can easily find this out by temporarily editing the following files:
/vendor/magento/framework/HTTP/PhpEnvironment/Response.php
/vendor/magento/framework/Controller/Result/Redirect.php
Open Response.php and add the following line to the beginning of the setRedirect function:
var_dump($url); \Magento\Framework\Debug::backtrace(false, true, false); exit();
Example:
public function setRedirect($url, $code = 302){
var_dump($url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this;}
Now open the second Redirect.php file and add this:
var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit();
after each line containing:
$this->url =
Example:
public function setRefererUrl(){ $this->url = $this->redirect->getRefererUrl();ihor
- 1 min read
There are situations in Magento 2 when page keeps loading and then you get 500 fatal error, memory limit, or timeout error. This is an infinite loop in the PHP code, when the same code is executed over and over again. It is related to some core Magento issues or, most likely, third party extension.
To debug an infinite loop and find the loop entrance, please follow the steps below:
1. Open the app/bootstrap.php file and add this code right after PHP open tag <?php in the next line
$_SERVER['MAGE_PROFILER'] = 'html';
2. Open the vendor/magento/framework/Profiler.php file and add this code to the beginning of "public static function start($timerName, array $tags = null)" function, e.g.
private static $firsttime = null;
public static function start($timerName, array $tags = null){ if (!self::$firsttime) { self::$firsttime = time(); } if (time() - self::$firsttime > 10) { //10 - is seconds to wait \Magento\Framework\Debug::backtrace(falseihor
- 2 min read
In case you work with a lot of different Magento instances as a temporary project you might want to have a nice method to check debug backtrace of some function execution in Magento 2 quickly without installing or enabling additional software on the server, e.g. Xdebug.
In this case, you can use the native Magento backtrace function from \Magento\Framework\Debug class and call it whenever you need:
\Magento\Framework\Debug::backtrace(false, true, false);
As a result, you will get this nice HTML debug-backtrace:
You can also call the exit function to stop further code execution right after the backtrace.
Here is more information about the backtrace method:
/** * Prints or returns a backtrace * * @param bool $return return or print * @param bool $html output in HTML format * @param bool $withArgs add short arguments of methods * @return string|bool */ public static function backtrace($return = false, $html = true, $withArgs = true)
Additional Debug Backtraceihor
- 3 min read
Hello there, Magento fans!Summer is hot this year the same as the extension updates we've prepared for you. Are you ready?
will work even better on different Magento instance since we’ve improved the HTML parsing for WebP conversion. Also, from now on you should face no errors during manual webp converting via bin/magento magefan:webp:convert command regardless of your Magento version.
Integrated better compatibility with other lazy load extensions and notification messages about invalid WebP PHP GD library on the extension configuration page will allow you to benefit from improved WebP extension.
Blog extension is a great contribution to your store especially if it is our we continuously work on improving. This month we’ve fixed the errors appearing on Magento 2.4.x.
Besides, datepicker won’t save wrong data if using en_US locale in the admin panel since we’ve fixed that too. If you want to track the Magento 2 Blog extension improvements you check the extension .
ihor
- 4 min read
Reasonable pricing is one of the milestones of a successful store. Not only does it improve your revenue, but encourages customers to buy more from you. You can set up special price, or offers discounts for the entire catalogue.
However, today we want to talk more about Magento 2 customer group pricing. It allows you to set different product prices in accordance with their quantity and . Yet, if you haven't had a chance to use this feature in your store, it's time to learn how to do it properly.
In this article, you'll learn more about Magento 2 tier pricing and how to apply it to the items you offer.
Shall we start?
Want to track price changes in your store? Get and display the lowest price over a certain period of time on the front end.
What is Magento 2 Customer Group Pricing?
Magento 2 Customer Group Pricing is the Magento feature that makes it possible to set discounts based on the customer group and product quantity.
In other words, it defines lower prices for different customer groupsihor
- 3 min read
Having your online store secure and with fewer bugs is one of the top priorities of each merchant. You can achieve it by updating Magento and .
It's a relatively easy task for the experienced developer. But updating an extension in Magento can be challenging if you perform it for the first time. So it's important to know the precise steps you have to take.
Note: the update instructions usually depend on the method used to .
Update Extension in Magento via Composer
If the extension files are located in the folder vendor/company/module-name, then the extension was installed using the composer. So you need to use the following steps:
1. Open CLI (Command Line Interface).
2. Navigate to Magento 2 root folder.
3. Run the following commands:
composer remove company/module-namecomposer require company/module-name ^x.x.x# 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
Note: if you don't wantihor
- 2 min read
Page Speed is taken very seriously by a lot of Magento stores since it directly influences your general website performance. That's why everyone constantly tries to improve it and looks for the best ways to do so.
In case you're checking your website speed in Google PageSpeed you can face the Serve images in next-gen formats issue. According to it, Google recommends you to save images in JPEG 2000, JREG XR and WEBP formats instead of old PNG and JPG. Best of all - WebP.
Never heard of it?
Find out more about what is WebP, why should you use it in your Magento 2 store and how is it different from PNG and JPG in this article about .
Implementing this Google recommendation gives you an advantage and allows to reduce the size of images by half.
Fortunately, there is no problem that wouldn't have a solution. So, to solve the Serve images in next-gen formats issue you have to install and enable the .
This module allows you to convert all current and future images into WebP fileihor
- 2 min read
Hello, Magento fans!
Since Magento is our favourite eCommerce platform and we all eagerly waited for Magento 2.4.0 release we are happy to bring the great news.
A Little Background
Our Extension made a great impact on Magento community. It's a valuable contribution to any Magento 2 store. That's why Magento got interested in adding it to Magento 2.4.0 core.
So, in the fall of 2019, Adobe Systems Incorporated, which owns the Magento platform, contacted us with an offer. Of course, we couldn't refuse, because Magefan are Magento fans.
Instead of writing new code from scratch, Magento asked about the integration, which we definitely supported.
Thus, we transferred the copyright for the "Login as Customer" extension to Adobe. Then in early 2020, we worked with the Magento Community Engineering Team on integrating our module into the Magento core. The module came out with code improvements and some new features.
What's New in Login as Customer?
Now Magefan Login as Customer extension isihor
- 3 min read
Magento development requires a lot of effort, especially when working with templates. Thus when you or override existing theme files, you need to know the exact location of the templates.
Since endless searching in the code won't suffice, you need some tips — Magento 2 template hints. So, in this article, you'll learn how to enable the Magento template path hints for admin and storefront in two different ways.
Before we get to the methods of enabling template path hints in Magento, let's define what they are first.
What are Magento 2 Template Hints?
Magento 2 template hints are the tips that help you define a .php block class or a .phtml template that corresponds to a specific page area on your Magento 2 store.
In other words, template path hints add a notation with the path of each template to help you locate the .phtml files more easily and edit them faster correspondingly. You can locate the code in the Magento file structure both on the frontend and the admin.
There are two ways toihor
- 4 min read
While everyone so desperately tries to make their way up to the top of SERP following the they pay little or no attention to one of the main things page speed could be improved with - Image Optimization.
If you , you will notice that images take a lot of your website loading time.
So, in order to get more traffic, you need to take care of plenty of things including images.
Many websites use outdated unoptimized images which definitely are not contributing to the website speed improvement since they take some time to load. It's been said that if the page takes longer than 3 seconds to load the majority of people are going to leave.
In case you really want to attract more customers with a fast-performing website you need to optimize your images.
We've prepared the top 3 tips for Magento 2 Image Optimization.
Tip 1 - WebP Images
PNG and JPG image formats are outdated and big in size. It makes them load longer and slow down your website performance correspondingly. Fortunatelyihor
- 2 min read
"There has been an error processing your request" is one of the most messages you can receive when working with Magento 2. Here is an example of this message:
What are the most common reasons for "There has been an error processing your request" message to appear?
Installation of the new Magento 2 theme or extension.
Updating Magento 2 or Magento 2 extension.
Changes in the template code.
Setting configuration.
Overloading of the server memory.
So, if any of the above-mentioned points are due you will see the default Magento error message "There has been an error processing your request". After that exception printing is disabled by default for security reasons.
Though you see this message you don't know what error is there to be fixed. In order to fix it, you need to find out the source of the problem first.
Fix "There has been an error processing your request" issue
Take the following steps to fix "There has been an error processing your request" issue in Magentoihor
- 1 min read
extension allows you to and move JS code to the bottom of the page automatically. That way you increase the website loading speed and eliminate render-blocking.
However, sometimes you don't need to move all JavaScripts to the bottom since there are some that aren't recommended to be moved there.
In this guide you'll learn how you can do that.
How to Defer Some JS Loading Automatically?
Navigate to Stores > Configuration > Magefan Extensions > Rocket Javascript and find the Ignore Deferred JavaScript With section. Then specify the strings you don't want to be moved to the bottom, each in a new line.
The extension will add data-rocketjavascript="false" attribute to them automatically so they will be ignored.
How to Defer Some JS Loading Manually?
In case you don't want to move some JavaScript to the bottom you just need to add the attribute data-rocketjavascript="false" to the <script> tag directly in your code:
Example:
Let's say you had the JavaScript tag like this:
<script> alert('Iihor
- 4 min read
The 1st place in Google SERP is a dream place every website is working hard on getting to. As plenty of studies show you'd probably click on the first 3 results Google gives for your query with little or no regard to the rest. Being at the top 3 is great, but still, the 1st place gives you far more authority and credibility. You have to be really good so that Google has the reason to put you there, right?
Your website or webpage success on Google is based on SEO, so everyone desperately wants to learn how to improve it. Consequently, those who've ever learned about SEO know how many things it is influencing and how many things you have to take care of in order to improve it on your website.
So, in order to outrun the competitors to improve your website SEO you have to:
Work hard on creating unique and useful products.
Do your research to target top-ranking and long-tail keywords.
Create informative and engaging content.
Pay a lot of attention to the MetaData.
Buildihor
- 3 min read
Basic Linux Commands
pwd - displays information about the current location in the file system (the path of the directory (folder) you are in);
dir, ls - shows a list of files and folders in the current directory;
cd - (change the current directory) allows you to move to another folder;
Example:
cd ../ - will move to a folder on a higher level;cd foo - will go to the child folder "foo";cd /var - will go to the "var" folder located in the root of the file system;
touch fine_name - create a new file named "fine_name";
mkdir dir_name - create a new folder "dir_name" in the current directory;
rm file_name - delete the file "file_name";
rm -r dir_name - delete the folder "dir_name";
cp origin_name new_name - copy files and folders;
mv old_name new_name - move files and folders;
ln -s origin_name link_name - create a symbolic link;
Search by Content
To search for a file by content, use this command:
grep -rnw 'path' -e 'some text'
Use the l modifier to display onlyihor
- 1 min read
If you already use for your HTML <img> tags and want to enable WebP for the CSS background as well, the proper way is to use multiple backgrounds in the CSS styling.
For example, you have an element with .png CSS background:
.minicart-wrapper .action.showcart.desktop .fa-shopping-cart:before { background: url(../images/icon-cart.png) no-repeat;}
To switch it to the WebP, you need to convert PNG/JPG/GIF image to WebP image manually using one of the free tools on the Internet. Save it in the same folder and use CSS like this:
body.webp-supported .minicart-wrapper .action.showcart.desktop .fa-shopping-cart:before { background: url(../images/icon-cart.webp) no-repeat;}body.no-webp .minicart-wrapper .action.showcart.desktop .fa-shopping-cart:before { background: url(../images/icon-cart.png) no-repeat;}
In this case, all browsers will get WebP images, except for ones that do not support WebP. They will load the .png image.
Note: if you use Magento 2 with "no-webp" & "webp-supported"ihor
- 3 min read
It is proven that information is perceived better by watching videos than reading a long one-piece text. Magento websites are not an exception. So, it's your cue to consider adding videos to your content, too.
There are multiple options to add YouTube videos in Magento. Starting from the default means and moving on to the advanced tools with , you can find the best solution for your needs.
Today, we'll cover both options to make your journey easier. Their features and performance metrics vary, so there's a lot to unveil.
Ready to get started?
How to Add YouTube Video in Magento?
You can use the WYSIWYG editor or page builder for content management. Fortunately, both of them offer a media tool to add audiovisual elements.
So, to add a video in Magento:
1. Navigate to the place where you'd like to insert a video and click on the Insert/edit media icon on the editor's toolbar.
2. Enter the video's link in the Source folder and specify its Width and Height in the General tab.
3. Switchihor
- 3 min read
Recently we got an "data-vocabulary.org schema deprecated and not supported by Google anymore. Please migrate to using schema.org types." error validating one of our website pages. The same error we got in Google Search Console.
This "data-vocabulary.org schema deprecated" error is related to the breadcrumbs structure data. We used "data-vocabulary.org/Breadcrumb" schema for the structured data, but Google supports it no longer.
You may also receive this error starting from April 6, 2020, in case you haven't converted your structured data scheme from data-vocabulary.org to schema.org.
Before we get to the point of how to fix the "data-vocabulary.org schema deprecated" error, let's make a few things clear.
What is Structured Data?
It is a specific HTML or JSON code on the web-page that helps search engine robots to analyze the page easier and structure the content for better understanding. When your page has a lot of elements it is hard for searchihor
- 1 min read
If you use Magento 2 and get an error like this:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading in vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php on line 72Trace:<pre>#1 file_get_contents() called at [vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php:72]#2 ReCaptcha\RequestMethod\Post->submit() called at [vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php:156]#3 ReCaptcha\ReCaptcha->verify() called at [app/code/MSP/ReCaptcha/Model/Validate.php:79]#4 MSP\ReCaptcha\Model\Validate->validate() called at [app/code/MSP/ReCaptcha/Observer/ReCaptchaObserver.php:93]#5 MSP\ReCaptcha\Observer\ReCaptchaObserver->execute() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:72]#6 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:60]...
when trying to login to theihor
- 1 min read
To apply lazy load for images in your Knockout template, first, make sure that extension is installed.
Then insert an image into the HTML template (my-template.html) like this:
<img data-bind="attr: {src: $parent.getPixelUrl(), 'data-original': thumbnail, alt: code_article, loading: 'lazy', width: '165', height: '165' }"/>
Example:
<div class="options-block" data-bind="foreach: getOptionBlocks(), afterRender: initLazyLoad()"> <div class="option-item" data-bind="attr: {'data-sku': sku}"> <div class="image-block"> <img data-bind="attr: {src: $parent.getPixelUrl(), 'data-original': thumbnail, alt: code_article, loading: 'lazy', width: '165', height: '165' }"/> </div> </div> </div>
Your view JS file should look like:
define([ 'jquery', 'uiComponent', 'ko',], function ($, Component, ko) { 'use strict'; return Component.extend({ defaults: { template: 'Vendor_ExtensionName/my-template' }ihor
- 1 min read
Social media is a powerful platform that generates tons of information throughout the world every day. That is why such networks as Facebook and Twitter are commonly used for marketing purposes by a lot of stores. It allows them to attract more attention to their content and correspondingly drive more traffic to their websites with the help of Open Graph tags.
However, sometimes it happens that aren't working as they are supposed to. Instead of a great featured image and newly written title and description, you see the outdated information or don't see anything at all.
If you're wondering what could possibly cause Facebook to pull out the wrong OG data instead of the up-to-date one the answer is pretty simple. Facebook Open Graph Cache.
So, in order to make sure Facebook shows the proper Open Graph Information you just need to clear the Facebook cache.
Follow these steps to clear Facebook Open Graph Cache:
1. Navigate to the Facebook Sharing Debugger, paste the URL to the pageihor
- 2 min read
Magento is one of the most powerful open source e-commerce platforms which provides online merchants with the solutions for their stores and full control over the functionality of their websites.
Magento is being used by a wide range of retailers from small regional stores to the ones on a global level with huge sales volume and extensive customer databases.
There are 2 versions of Magento with the 1st said "to extinct" by June 2020. There are plenty of reasons you might want to , but let’s analyze the main of them.
So, the main reasons to migrate from Magento 1 to Magento 2 are:
1. Support
As it was stated by June 2020 Magento 1 will no longer be supported meaning there won’t be any updates for the platform. This is the main reason for migrating to Magento 2 since without support there can be crucial consequences on security, not speaking about the inability to stand out the competition of constantly developing Magento 2 websites.
2. Security
The end of support will correspondinglyihor
