Page 8 - Monthly Archives: 2023
- 2 min read
Magento flexibility allows you to display CMS blocks in a multitude of ways. However, for those of you with technical knowledge, there are only two options.
You can either , or call them in the PHTML file. Today we'll focus of the second one.
Call CMS Block in PHTML File
To programmatically call the CMS block in .phtml template file use this code:
<?php echo $this->getLayout() ->createBlock(\Magento\Cms\Block\Block::class) ->setBlockId('my_cmsblock_identifier') //replace my_cmsblock_identifier with real CMS bock identifier ->toHtml();?>
Note: you need to for this method to work. If the CMS block is disabled or does not exist, this code will not display any content.
Using createBlock method is fast but not ideal in terms of best practices.
So what you can do is add a CMS block into your block using layout. Use the following code in a proper layout XML handle file and don't forget to once the layout is changed:
<referenceBlock name="my-main-phtml-block">ihor
- 1 min read
Although CMS blocks are managed directly from Magento admin using widgets there are other ways to .
If you have some technical skills you can just call CMS block in Magento using the XML file.
Call CMS Block Using XML File
Use the following code to add CMS blocks using Magento 2 layout XML:
<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="unick_block_name">
<arguments>
<argument name="block_id" xsi:type="string">my_cmsblock_identifier</argument>
</arguments>
</block>
</referenceContainer>
You need to replace "my_cmsblock_identifier" with your CMS block Identifier or ID (we recommend using Identifier).
Display CMS Blocks Dynamically (by Date)
Even if you add CMS blocks programmatically using the XML file, they will still be static. It means that you'll need to replace the identifier or disable a block manually. But not if you use the .
This way, you can display your CMS blocks dynamically, by different dates, times and days of the week.
But that'sihor
- 9 min read
Magento 2 static blocks are a great way to drive customer's attention to certain products, offers, or services. Although creating is super easy, adding them to pages is quite a challenge.
All because there are different ways to insert CMS blocks in Magento. Everything depends on how and where you prefer them to appear.
This guide covers the main tools and locations to add static blocks, including how to display them dynamically: by custom group, date or other conditions.
Key takeaways
You can display CMS blocks in Magento through category settings, widgets, the WYSIWYG editor, and page builder.
Category settings are the fastest way to add banners in Magento, but they allow placement in predefined areas only — at the top of the category, near the description.
Magento widgets are the most popular method to insert CMS blocks since they give full control over the pages and containers where the block will appear.
The WYSIWYG editor and Page Builder let you add blocks directly into page contentihor
- 2 min read
Choosing the right theme for your store is one of the first steps you take when . It should not only represent your brand using custom layouts and templates but be user-friendly, fast and SEO-optimized.
The variety of Magento 2 themes on the market is growing. It allows you to find any theme you want on Magento Marketplace or Theme Forest. And once you make up your mind and choose the best , you need to know how to install and apply it to your store.
Since Magento has deprecated the WebSetup Wizard starting from Magento v2.3.6, you can now install Magento 2 theme only in the command line: via composer or archive. In the first case theme files will be located under vendor and, using the archive, you can find the theme files under app/design.
Install Magento 2 Theme via Composer
Before you install a theme in Magento 2, it is recommended to switch to .
1. Navigate to your Magento 2 root directory, using "cd" and run the following command:
composer require <vendor>/<name>
e.g. composerihor
- 2 min read
When it comes to purchasing decisions, customers pay attention to a lot of things in your store. Loading speed is one of the most important ones. While you can improve website speed by enabling lazy load or images or disabling the JS bundling, it is not always enough.
In this guide, you'll learn how to lazy load CMS blocks in Magento using the and Pages Extension.
CMS Blocks Display Modes
We've created two CMS pages with the same content: a banner and a product slider. One page contains a CMS block with default display mode, second — a CMS block with display mode Ajax load on first scroll.
Now, let's compare display modes Default and Ajax load on the first scroll.
CMS Block - Products Included In DOM
CMS Block - Products Loaded Via Ajax Request
Param
Default mode
Ajax load on first scroll mode
Page Size
26.2kb
15.9Kb
Time To Load Page Content
783 ms
591 ms
DomContentLoaded
1.43 s
1.11 s
Page Load
3.13 s
2.58 s
Page speed score is better if some elements like sliders, and widgetsihor
- 1 min read
If you decided to remove the by Magefan, please follow the steps below. You can contact our team for a free consultation in case you have any issues with Magefan's theme.
Remove Theme Files
1. If you can find the theme files in the folder
app/code/Magefan/ThemeOptimizedapp/design/frontend/Magefan/optimized
then remove these folders. Also, you can remove other Magefan modules you don't need in the app/code/Magefan.
2. If the theme was installed via the composer and its files are located in the folder
vendor/magefan/theme-frontend-optimized
then run the composer CLI command to remove it
composer remove magefan/theme-NAME# replace NAME with:# frontend-optimized - for Optimized Magento 2 Theme# frontend-optimized-plus - for
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 Theme Dataihor
- 1 min read
If you need to update the by Magefan, please follow the steps below.
Note: that the update instructions depend on the method the Optimized Magento 2 Theme was installed with.
Update using composer
If the Optimized Magento 2 Theme was installed via the composer (check if vendor/magefan/theme-frontend-optimized folder exists), then you need to run these simple CLI commands in Magento 2 directory:
composer remove magefan/theme-NAMEcomposer require magefan/theme-NAME ^x.x.x# replace NAME with:# frontend-optimized - for Basic plan# frontend-optimized-plus - for Plus 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, check this guide on how to .
Update using archive and FTP
If the Optimized Magento 2 Theme was installed via FTP (check if app/code/Magefan/ThemeOptimized folder exists), then follow these commands:
1. Download the latest version of the Optimizedihor
- 1 min read
You can install by Magefan, using the composer or archive installation method.
Do you want us to install the Optimized Magento 2 Theme for you? Let our technical engineers do it – check out our .
Note: if you want to install the Optimized Magento 2 Theme Plus please navigate to your Magefan Account > My Downloads > Install via Composer to get the composer installation instructions.
Installation via composer (recommended)
Open command line.
Using command "cd" navigate to your Magento 2 root directory.
Run CLI commands:
composer require magefan/theme-frontend-optimized# Authentication required (repo.magento.com)# Get your Magento Marketplace authentication keys or use these: # Username: 7c018006799466c681ad507e27904677# Password: 289077c86e811661a8f7751828485d3aphp 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 .
Installation using archiveihor
- 5 min read
Even though you improve and focus on getting more organic traffic, sometimes you need to change your approach to increase conversions. While SEO will help you to drive traffic to your store, it doesn't guarantee this traffic will bring conversions.
So, if you want to improve the conversion score, since there are people who browse your website but buy nothing, you've landed on the right page.
Today we want you to learn more about Google Ads Dynamic Remarketing and help you to set it up for your store with .
Before we start, let's define what dynamic remarketing is and how it is different from remarketing.
What is Google Ads Dynamic Remarketing?
Google Ads dynamic remarketing is the campaign you can set up to display personalized ads to people who visited your website previously but didn't make a purchase.
Unlike remarketing, dynamic remarketing allows you to go one step further and display ads with products and services people visited.
A great advantage is the dynamic remarketingihor
- 3 min read
Configuration of the store URLs in Magento 2 is one of the first steps you'll take while . Once you configure base and admin URLs, it will be easier to move an entire store from one location to the other without having to update the URLs.
Besides, understanding the Magento URL structure is an advantage while developing a store. In this article, you'll find the steps on how to configure Magento store URLs, as well as some other recommendations.
Ready? Let's begin!
Types of URLs in Magento 2
After you , you'll get a storefront base URL and admin URL. All the internal links are then defined with the help of the variables added to the base URL. This pattern is rather convenient since it enables you to move your store to a different location without changing all the links.
In general, there are 3 types of URLs in Magento.
URL type
Representation
Base URL
http://www.example.com/magento/
Secure Base URL
https://www.example.com/magento/
URL with IP address
http://###.###.###.###/magento/ihor
- 2 min read
If you're a Magento developer, you certainly know that effective store management often requires programming work. There are lots of tasks you need to perform — from running static content deploy and to and media URLs. Some of these are rather time-consuming or even complicated at times.
However, it is much easier if you know the proper methods to use.
In this article, in particular, you'll learn how to get media URLs in Magento 2.
Get Media URL Using Dependency Injection
The dependency injection method is among the most common ones when it comes to getting media URLs in Magento.
So, to apply it, go to your phtml block file and create a _construct function:
public function __construct ( \Magento\Store\Model\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; }
After that you can get a media URL in your phtml file:
$mediaUrl = $this ->_storeManager-> getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
echo $mediaUrl;
Get Media URLihor
- 2 min read
The began on February 24, 2022. It was a day that changed us and our way of living. We thought these terrific events would last for a few days or at least a . Unfortunately, this horrible war that has already taken so many lives of adults and children has lasted for a and is still not over.
Donations have become a part of Ukrainians’ ordinary lives throughout this year.
And Magefan is not an exception. Our company keeps working and donates to the humanitarian aid organizations.
Here are some main foundations we support with our monthly donations.
Comeback Alive Fundation
Comeback Alive is one of the biggest Ukrainian charitable foundations. Ukrainians and people from around the globe had donated to this fund over 140 million dollars since February 24, 2022. The main project of this fund is Army Assitance. This is also one of the first charity funds that has been providing army assistance since 2014 when russia first invaded Ukraine.
Prytula Foundation
Prytula Foundation is anotherihor
- 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/GoogleTagManagerapp/code/Magefan/GoogleTagManagerPlusapp/code/Magefan/GoogleTagManagerExtra
then remove this folder.
2. If the extension was installed via the composer and its files located in the folder
vendor/magefan/module-google-tag-manager
then run composer CLI command to remove it
composer remove magefan/module-google-tag-manager*
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 Google Tag Manager log and extension configurations.
1. Just in case please make a fullihor
- 1 min read
If you need to update by Magefan, please follow the steps below.
Note: the update instructions depend on the method the Google Tag Manager extension was installed with.
Update using composer
If the Google Tag Manager module was installed via the composer (check if vendor/magefan/module-google-tag-manager 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:# google-tag-manager - for Basic plan# google-tag-manager-plus - for Plus plan# google-tag-manager-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 Google Tag Manager module was installed via FTP (check if app/code/Magefan/GoogleTagManager folder exists), then follow theseihor
- 1 min read
You can install by Magefan, using the composer or archive installation method.
Note: if you want to install the or Extra please navigate to your Magefan Account > Downloads > Install via Composer to get the composer installation instructions.
Installation via composer (recommended)
Open command line.
Using command "cd" navigate to your Magento 2 root directory.
Run CLI commands:
composer require magefan/module-google-tag-manager# Authentication required (repo.magento.com)# Get your Magento Marketplace authentication keys or use these: # Username: 7c018006799466c681ad507e27904677# Password: 289077c86e811661a8f7751828485d3aphp 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 .
Installation using archive or FTP
Download Google Tag Manager Extension ZIP-Archive from magefan.com website (not GitHub or other sources).
Extract files.
Copy app and lib foldersihor
- 2 min read
As you know, is quite a demanding process. It calls for full attention to the details and the ability to make quick decisions. Especially when it comes to customer-related information.
Just like , you should know how to get customer data by customer ID in Magento. And this is exactly what you'll learn today.
There are a few methods to use, so we'll look at each of them in detail.
Get Customer Data by Customer ID Using Factory Method
The factory method is among the most common ones. So, the code below will help you to get customer data by customer ID:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerFactory = $objectManager->get('\Magento\Customer\Model\CustomerFactory')->create();
$customerId = 1;
$customer = $customerFactory->load($customerId);
print_r($customer->getData());
echo $customer->getEmail() . PHP_EOL;echo $customer->getFirstname(). PHP_EOL; echo $customer->getLastname(). PHP_EOL;
Get Customer Data by Customer ID Using APIihor
- 2 min read
As you know, shipments are crucial for . Creating a shipment is the last step in the order workflow done manually after an order is invoiced. While it's possible to create a shipment in Magento programmatically, a much easier option for you is to create a shipment in the Magento admin panel.
And in this article, you'll learn how to do that.
To create a shipment in Magento 2:
1. Go to Sales > Orders and find the order you want to create a shipment for.
2. Press the Ship button in the top menu panel.
3. Review the Order & Account Information and Address Information sections. Check if all the data is correct and press the Edit link to add some changes, if necessary.
4. Move to the Payment & Shipping Method section. Press the Add Tracking Number button to specify the shipping information. You have to choose a Carrier and set the Title and Number. It is easier to track the package this way.
5. Check the item's source in the Inventory section and set the Qty to Ship in the Itemsihor
- 2 min read
Creating and adding different ensure visitors can find relevant content on your blog faster. However, it is equally important that readers can navigate through your blog post content. One of the best ways to achieve that is Post Contents.
In the Magefan's , post contents is generated based on the <h> tags and added through a widget. So, today, you'll learn how to do that.
Note: Blog Post Contents feature is available only in the edition.
How to Add Contents to Post Content?
1. Navigate to Content > Blog > Posts and choose a blog post you'd like to add the contents to.
2. Jump to the Content section and click on widgets.
3. Choose Magefan Blog Extra Extension - Blog Post Contents as a Widget Type and press Insert Widget.
Don't forget to Save your post and check the contents on the frontend.
However, if you want to display post contents in the sidebar, keep reading.
How to Add Contents to Blog Sidebar?
1. Go to Content > Blog > Configuration > Sidebar > Post Contentsihor
- 1 min read
A blog sitemap plays a vital role in your page rankings. If it is not configured correctly your blog pages won't be crawled, indexed and ranked properly. Since our allows you to in a few clicks, all you need to do is submit it to search engines.
However, if you don't want some pages to be crawled and indexed, you simply need to exclude them from the sitemap. And you'll learn how to do that in this article.
Note: this feature is available in the plan.
To exclude pages from the Shopify blog sitemap:
1. Go to Apps > Magefan Blog > Posts and choose a you'd like to exclude from the sitemap.
2. Find the Search engine listing section and switch the Exclude from XML Sitemap option to Yes.
3. Save a blog post, go to the blog sitemap and check if a post is removed from it.
Note: the Exclude from XML Sitemap option is available for blog posts, category and tag pages, so you can exclude these pages from the blog sitemap if you like.
Once you finish configuring the blog sitemap andihor
- 4 min read
Hello, dear friends,
We are ready to share with you the first news and updates digest of spring 2023. A lot of great updates from Magefan this March. Let’s start!
New features of the !
Big updates to our bestseller – Magefan Blog! We added an option to set a custom blog category canonical URL. Another great addition — is an option to reset extension configuration options to use system values.
We also updated some localization vocabularies and improved import for Hubspot Wizard and via CSV. We made some design improvements for compatibility with different themes. New PHP 8.1 code compatibility changes was added too.
We have also fixed the "Previous" and "Next Post" links that lead to the wrong articles.
New features of !
We changed the default value for the "Apply By" option. We also removed the option "Assign Product With Attributes" from the category. Now, this option is hidden and for technical use only.
In this version, you will also be able to rename categoriesihor
- 2 min read
XML sitemap is one of the most important SEO concepts that helps to get your pages crawled and indexed. Think of it as a roadmap for search robots who need to discover new "routes" (pages) while crawling your website.
As you might know, Shopify generates a sitemap.xml file with all the product images, pages and collections automatically. However, in our we have our custom blog XML sitemap and in this guide, you'll learn how to find and configure it.
How to Find Shopify Blog Sitemap?
Your blog sitemap will always be available via the following path by default:
https://your-shopify-domain.com/a/blog/sitemap.xml
You can also find the direct link in the sitemap configuration section which we're covering below.
Note: if you've changed your app proxy — /a/blog/ — the sitemap path will be different.
Once you find your blog sitemap you can submit it to Google and other search engines.
Google Search Console Throws Errors
Sometimes it happens that Google Search Console can readihor
