Page 25 - Blog
News, insights and resources from the world of e-commerce
- 2 min read
Sometimes, during you need to get the store Information programmatically. You may need to get a current Store ID, Store Code, Name, Website ID, or .
To retrieve this data use the singleton instance of the following class:
\Magento\Store\Model\StoreManagerInterface
For example, you can include it in your class constructor and then call:
<?phpnamespace \MyCompany\ExampleModule\Model;class Example{ private $storeManager;
public function __construct(
...
\Magento\Store\Model\StoreManagerInterface $storeManager,
...
) { ...
$this->storeManager = $storeManager;
...
}
/** * Examples */ public function execute() { /* Get Current Store ID */ $storeId = $this->storeManager->getStore()->getId(); /* Get Current Store Code */ $storeCode = $this->storeManager->getStore()->getCode(); /* Get Current Store Name */ $storeName = $this->storeManager->getStore()->getName(); /* Get Current Storeihor
- 1 min read
Get URL in the .phtml template files
1. Get URL of the store homepage (http://domain.com/):
<?= $this->getUrl() ?>
2. Get URL of some page, e.g. "Contact Us" (http://domain.com/contacts/):
<?= $this->getUrl('contacts') ?>
3. Get URL of the theme static file, e.g.:
app/design/frontend/ThemeVendor/theme_name/web/css/custom.cssapp/design/frontend/ThemeVendor/theme_name/Magefan_Blog/web/js/lazyload.jsapp/code/Magefan_Blog/view/frontend/web/js/lazyload.jsvendor/magefan/module-blog/view/frontend/web/js/lazyload.js
use the following code:
<?= $this->getViewFileUrl('css/custom.css') ?><?= $this->getViewFileUrl('Magefan_Blog::js/lazyload.js') ?>
4. Get URL of the static file in pub/media:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();$mediaUrl = $objectManager->get(Magento\Store\Model\StoreManagerInterface::class) ->getStore() ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
<?= $mediaUrl ?>wysiwyg/image.png
Attention! You should not use media files in the themeihor
- 2 min read
Hello there, Magento fans!
Hey hey! It's been a while since we last shared the Magefan updates. Are you ready for the January compilation of news?
Then, let's start!
We would like to begin with the new module that has been released recently. With the extension you can forget about a broken website and increased bounce rates during the deployment time.
There is no need for you to lose profits or choose the most inconvenient time to run deployment commands when you can do this harmlessly with this module.
— extension that helps you increase your website loading speed and boost performance — is even more beneficial now. We have improved HTML tags style attribute background parsing and module compatibility with MGS themes. Moreover, we have fixed the following error:
TypeError: strtolower() expects parameter 1 to be string, null given in app/code/Magefan/WebP/Plugin/Magento/Framework/View/Element/AbstractBlock.php:69 .
We encourage those of you who haven’t yet updated to v2.1.1ihor
- 3 min read
One of the most unique Magento 2 offers you to create is a virtual product. But what is virtual product in Magento, and why is it so special?
It stands out because you can neither feel it tangibly, set the weight, or download a virtual product in Magento 2. Some of the common examples of this product type are memberships, services, subscriptions, and warranties.
They can be sold individually or as a part of or . The configuration section contains the familiar fields you can fill out easily. Today, you'll learn how to do it in more detail.
What is a Virtual Product in Magento 2?
Magento 2 virtual product is nontangible and doesn't have a physical representation. Thus, it can be neither shipped nor delivered. The only indication that a customer bought such a product is the confirmation email.
Some of the most popular examples of virtual products are subscriptions, warranties, memberships, etc. You can sell virtual products individually or as a part of other product types.
How to Create Virtualihor
- 3 min read
The popularity of downloadable products has increased drastically, both globally and in Magento in particular. It is not a surprising fact, though. Such products as eBooks, music, videos, , updates, or instruction manuals are being actively sold. They don’t require additional manufacturing or shipping, which is an advantage.
Together with other , the platform allows you to create downloadable products with free samples. The process doesn’t differ much from that of a simple product. However, you have to configure the before creating a downloadable product.
But let’s sort everything out. Keep reading to learn how to create a downloadable product in Magento 2.
What is a Magento Downloadable Product?
Magento downloadable product is a digital type of Magento product customers can download from your store. As mentioned above, E-books, manuals, and applications are the best examples of this product type.
When creating downloadable products, you have an extensive set of options to set and makeihor
- 1 min read
In case you use some Geo IP modules (like our Magento 2 and Extensions) and have the Varnish installed, then you need to make some additional configurations for it.
The simplest configuration is to add the following lines to the varnish config file:
if (req.http.cookie !~ "PHPSESSID=" && req.http.User-Agent !~ "bot" && req.http.User-Agent !~ "loader") { return (pass); }
In this case, the first customer visit will not be cached by varnish, the php Magento will generate the right cookies, switch to the right store view and change the currency.
However, the drawback of this approach is that the store view will be displayed without varnish cache during the first visit. If you want to avoid this you can configure the varnish cache to have different caches for different countries
To achieve that you have to configure the Geo IP with Varnish. Follow this link for step-by-step instructions.
- 4 min read
One of the many perks of Magento 2 is the variety of products it allows you to create. Yet, Magento 2 bundle products definitely stand out. It's a unique since it allows customers to customize product attributes available in a bundle.
Many of you would find a huge similarity between bundle and and there is some. However, these two types of products still have some differences you should know about.
If all these concepts confuse you a bit, you've landed on the right page. Today you'll not only learn more details about Magento bundle products but find out how to create them in Magento 2.
Difference Between Magento 2 Bundle Product and Grouped Products
When buying grouped products a customer can remove or add some items to the set (group), but not choose any product option. Magento 2 bundle products work the other way around. Besides, they consist of simple and .
e.g. If you have a grouped product that consists of a sports bag, uniform, and sneakers, customers can easily remove one ofihor
- 2 min read
No one likes to see their website broken during the since it scares off the potential customers and causes them to bounce. Not exactly the prospective successful Magento 2 store owners look for.
Fortunately, there is the extension that fixes this and reduces the downtime to zero. It allows you to run the deployment commands with no website breakage. Speaking of which, here is the list of the deployment commands you have to run to reduce the downtime to ZERO.In order to redeploy Magento completely, you have to run
bin/magento magefan:zero-downtime:deploy
If you only want to deploy dependency injection (bin/magento setup:di:compile), then use
bin/magento magefan:zero-downtime:deploy -d
To run the Magento static content (bin/magento setup:static-content:deploy) use
bin/magento magefan:zero-downtime:deploy -s
In case you want to run multiple parameters script, use the following command
bin/magento magefan:zero-downtime:deploy -d -s
If you want to pull data and switch to a specificihor
- 2 min read
is the extension that solves your problems with the 503 maintenance pages during deployment time. It prevents your website from breaking and you from losing potential customers even when running the commands. Moreover, the configuration is really simple. So let's get to it.
Zero Downtime Deployment configuration has 4 different sections: General, Instance Files and Folders, Composer and Git within which you can find different options.
Following steps to configure Magento 2 Zero Downtime Deployment extension:
General
1. Navigate to Stores > Configuration > Magefan Extensions > Zero Downtime Deployment.
2. Enable the extension.
3. Select the Static Content Deploy option. You can Deploy Only Enabled Themes or Deploy All Themes.
4. Define how many jobs you want to be processed parallelly during deployment in the Count of Jobs For Parallel Processing Of Static Content Deploy field.
5. Choose whether to Enable all Caches After Deploy since sometimes some of them can be disabled after deploymentihor
- 2 min read
Magento 2 grouped product is one of many the platform offers. As you might know, it features a set of different related simple products to increase the chances of customers buying more items.
In this case, every can be purchased either separately or as a group. However, every item is listed as a separate product in a shopping cart.
Since Magento grouped products are relatively easy to create you'll learn all the necessary steps in this guide.
To create Magento grouped products:
1. Navigate to Catalog > Products and choose Grouped Product from the Add Products dropdown.
2. Enable the grouped product and choose the Attribute Set for it.
3. Enter the Product Name, specify the SKU, and set its Stock Status.
Note: you can't set the Price and Quantity since they are set separately for each product of the group.
4. Choose a Category Magento grouped product.
5. Set the Visibility of the grouped product.
6. Enter the date range in the Set Product as New From/To field to determine how long theihor
- 7 min read
A configurable product is one of the many the platform offers. It's called Magento configurable product since it allows customers to "configure", choose different options, such as size, colour, or material, to buy a product.
It gives people more flexibility when shopping. No wonder it's the most popular product type in Magento, you definitely need to know how to use.
So in this guide, you'll learn more about configurable products, how they work and how to set them up in your store.
Simple vs Configurable Products: What's the Difference?
People often confuse Magento simple products with configurable ones. That's why, before we get to creating configurable products, we should make this one clear.
Although they look similar at first, simple and configurable products play different roles. Besides, they influence both customer experience and backend management in different ways.
A simple product in Magento 2 is the basic product type. It represents a single item which has its own SKU (Stockihor
- 4 min read
Magento 2 simple products are the most basic and essential Magento products. The simple product has no variations. It is sold individually since it has a single SKU. However, it can also be purchased as a part of a , or .
Following steps to create a simple product in Magento 2:
1. Navigate to Catalog > Products and choose Simple Product from the Add Product dropdown.
2. Enable or disable a simple product.
3. Choose the Attribute Set you want this product to have. Magento provides the default attribute set. However, you are able to choose from various other options. Besides you can add a or a .
4. Set the Product Name and SKU.
5. Set the product Price.
There are cases like sales, promotions or any other kind of offers when you need to set an Advanced Pricing for a product.
e.g. you might use it to or for configuring catalog price rules
Set Special Price, a price customer will see during sales or under other conditions.
Choose the Special Price From and To Date.
Set the Cost, the priceihor
- 4 min read
If you want to take your store to the next stage and create a store, the first thing you have to cover is localization. Providing customers with content in their local language creates a personalized experience and encourages them to stay.
The Magento 2 translate inline tool is what can help you out with this task. It is available by default and convenient to work with. You can use it for your localization tasks to ensure relevant content is displayed after customers .
Today, we'll closely explore Magento 2 inline translation and determine whether it's worth it. We'll also cover other advanced tools to enhance your translation management.
So, shall we start?
What is Magento 2 Inline Translation?
The Magento 2 translate inline tool is a default Magento localization instrument that enables translation from the frontend. You can just hover over the interface element and add its translation right on the storefront.
It works best with short text elements, such as buttons and labels, andihor
- 2 min read
Once you assign attributes to the , each product has a unique set of characteristics. However, when you need to change that you find that Magento doesn't offer any bulk option for that. You need to change the attribute set for each product, one by one. But not if you have the .
So, today you'll learn how to bulk change attribute sets for multiple products just in seconds.
To bulk change product attribute set in Magento 2:
1. Go to Catalog > Products and check all of the products you want to change the attribute set for, or choose the Select All option.
Note: you can and then change the attribute set for all products in a specific category.
2. Select Change Attribute Set from the Actions dropdown menu and choose the attribute set you want to change a current one to.
3. Confirm that you want to Change Attribute Set for selected products.
4. Check changed product attribute sets.
If you prefer to see how to bulk change attribute set in Magento 2, check this short video.
As youihor
- 2 min read
Although Magento enables you to create multiple , there is no option to edit their values in bulk. That's why it takes you a while to go from one product page to another and update them. But now if you know how to bulk edit product attributes in Magento.
You do not need to update any files or learn code editing here and now. All you need is — an extension that allows you to bulk edit product attributes directly from the products grid.
To bulk edit product attributes in Magento 2:
1. Go to Catalog > Products and click on one of the products you want to edit to see the editing menu.
2. Tick all products you want to update attributes for and change the attribute value in a corresponding field. Then press Apply.
3. Once you apply new values, you'll see them change as per your edits. However, for them to be saved you need to press the Save Edits button.
That's how you bulk edit product attributes in Magento 2. Just in a few clicks.
If you want to see how this actually works, check thisihor
- 2 min read
Originally, there is no filter products by category option in Magento 2 product grid. That is a little inconvenient making your search for specific products of some category when you want to update their information. It is not a big deal when you have a thousand , but what about several thousand?
Correspondingly, the product grid category filter saves a lot of time enabling you to sort products by category in seconds. In this article, you will learn how to filter products by category in the product grid with no code updating.
You simply need the that already has this feature. But the category filter is not the only feature you get with this extension.
Follow these steps to filter products by category in Magento 2 product grid:
1. Navigate to Catalog > Products and press the Filters button.
2. Choose the Category you want to filter products by in the category filter and get all products from that category listed in the grid.
So, what now?
You have filtered the productsihor
- 4 min read
Magento 2 blog is the best marketing tool you can use to attract more customers to your store, share some relevant information and gather loyal subscribers who strive to learn more about the experience shared in your blog posts. Content is king and it would be a crime not use it to its full extent to get more traffic.
By managing a blog on your Magento 2 store you create a community of followers. They share your idea and want to receive updates on the topics they are interested in on a regular basis.
Correspondingly, except for sharing your blog posts on social media, you need to consider emailing them to your subscribers. Having hundreds or thousands of blog subscribers it will be impossible to do it manually.
That is why in this article you are going to learn how to email your posts automatically using the Mailchimp, all-in-one Email Marketing Platform.
Before you start configuring your Magento 2 blog posts emails, you obviously need to set up an account on Mailchimp: fill out theihor
- 9 min read
Managing a growing business can sometimes be quite challenging. However, by delegating responsibilities to different members of your team, you can make it less stressful.
Magento 2 user roles help with that. They allow you to grant users access to different sections of your backend. This not only declutters the space but also allows you to protect the admin from any unauthorised changes and improve .
So, in this guide, you will learn how to create Magento user roles and understand how to leverage them to your benefit.
What Are Magento 2 User Roles?
Magento user roles are permissions to access certain admin sections and functionality, restricted to certain admin users. They allow you to define what parts of your backend a user can view or modify.
This helps to avoid unauthorised changes, streamline the workflow, and protect sensitive data. It is important for delegating tasks, managing teams, and, of course, securing data.
However, let us give you a full picture of why the Magento user rolesihor
- 1 min read
This year Magefan is proud to be among the Silver Sponsors of an online MageCONF that will take place on October 24, 2020.
Mageconf 2020 is a must-attend online conference that allows you to dive into the world of unique shared experience presented by Magento expert agencies, service providers and developers, learn about the latest eCommerce trends and innovations.
Register now for free. Don’t miss it!
- 2 min read
Since Magento is a complex platform, it might be hard to cover all the sections on your own. You need to create other Magento admin users who will manage products, monitor orders and create email templates, etc.
However, you must grant each user access only to certain areas of your store to ensure high .
So today you'll learn how to create admin users in Magento and .
Magento 2: Create Admin User in the Admin
1. Go to Admin Panel > System > Permissions > All Users and press the Add New User button.
3. Fill out the new user Account Information:
Set the User Name that will be used during login, and specify the First and Last Names.
Enter the user's Email.
Create a Password, and confirm it in the Password Confirmation field.
Choose the interface for the user in the Interface Locale.
Note: we recommend choosing English since Magento has some issues in other locales. If you choose some other language make sure you of your preference.
Active new user in the This account is select box.
4ihor
- 2 min read
In case you use one of the Amasty extensions, e.g. Amasty Layered navigation, you may face the issue of the broken blog featured images after the upload.
We have found the issue in Amasty_Shopby extensions, that breaks some other extensions using image upload functionality, including our .
Amasty_Shopby in this file:
app/code/Amasty/Shopby/etc/adminhtml/di.xml
adds the plugin to Magento\Catalog\Model\ImageUploader model.
Judging from the code in the following file:
app/code/Amasty/Shopby/Plugin/Catalog/Model/ImageUploaderPlugin.php
it looks like some fix Amasty added for Magento 2.3.4. and the issue lies in the plugin beforeMoveFileFromTmp.
The original Magento MoveFileFromTmp declaration looks like this:
public function moveFileFromTmp($imageName, $returnRelativePath = false)
and Amasty's plugin missing the second parameter $returnRelativePath:
public function beforeMoveFileFromTmp(\Magento\Catalog\Model\ImageUploader $subject, $path)
So, basically, Amasty's plugin kills the second functionihor
