Guide to Magento 2 Static Blocks

- E-Commerce, Magento 2, Our extensions

Magento 2 Static Blocks: create, import, and export

Below, we are going to discuss Magento 2 static blocks. It is hard to overestimate the importance of Magento 2 CMS pages for an average e-commerce website. They play a pivotal role in creating a unique and attractive storefront. Homepage, news blocks, promotions, and other store sections may incorporate CMS pages to deliver a more abundant shopping experience. Also, pages composed within the Magento 2 Page Builder are always associated with various CMS elements. Despite such frequent appearances, Magento 2 doesn’t let you import-export CMS elements: pages, blocks, and widgets. However, you can do that with the Improved Import and Export extension. In this Magento static blocks tutorial, you will learn how to import CMS blocks. We focus on such aspects as a proper import table and an import job that simplifies your daily chores.

Along with the step-by-step instructions, the article provides explanations of every static block attribute. Also, you will find sample files that you can use as a reference for your Magento 2 static block imports. We describe prerequisites for importing/exporting statics blocks in Magento 2. After that, you will learn how to transfer CMS blocks between Magento 2 websites. Additionally, we touch upon the topic of composing and editing static block tables.

What Are Magento 2 Static Blocks?

So, static blocks, or CMS blocks, are snippets of HTML that can be used to add repeating content patterns to CMS pages. Consider them your ‘Lego blocks’ when composing and building store content. Static blocks can be anything: banners, sliders, etc.

When it comes to optimizing workflows, if you are building several typical stores, or want to migrate from one to another, composing static blocks manually takes much more time than intended. That’s why in this article we will describe how to import static blocks. But let’s take a look at their manual configuration first.

How to Create Magento 2 Static Block

Follow these steps to create a new CMS block in Magento 2:

  1. Navigate to Admin -> Content ->Blocks.
  2. Click the Add New Block button.
    Magento 2 Static Blocks: add new block
  3. Activate your new Magento 2 Static block.
  4. Type its name.
  5. Create a unique identifier for this CMS block. You will use it to implement this block into other pages.
  6. Choose a store view to display the block.
  7. Specify the content elements used in your new Magento 2 static block. You can use templates here to simplify the routine configuration.
    Magento 2 Static Blocks: block configuration
  8. When done, click Save.

Magento 2 Static Blocks Import & Export Tutorial

Below, you will learn everything you need to know about importing and exporting static blocks in Magento 2.

Prerequisites for Magento 2 Static Block Import & Export

For importing and exporting static blocks, including blocks composed with Magento 2 Page Builder, we will be using the Improved Import and Export extension for Magento 2. The module is a full-featured import/export tool that can help you reduce store management time by offering automated product catalog updates, order updates, and import and export of every Magento 2 entity you can think of.

The extension comes with the following features:

  • Import and export of all product types, product attributes, orders, categories, static blocks, CMS pages, cart price rules, MSI, and others.
  • Import and export of B2B entities, such as companies, requisition lists, shared catalogs, quotes, and negotiable quotes.
  • Support of direct file upload, FTP, SFTP, direct URL, Dropbox, and Google Sheets as import sources.
  • Support of CSV, XML, Json, XLSX, and ODS file formats.
  • Mapping of CSV file separators and attribute mapping.
  • Filers and conditions including price, category, and other entity attributes.
  • Import speed of ~3000 per minute on a decent server configuration.

This is just a small part of all the features available in the Improved Import and Export extension. For the full feature list refer to the product page.

Sample Tables with Magento 2 Static Blocks

In this section of our Magento static blocks tutorial, we’d like to draw your attention to sample data. There are two ways to get sample tables with static blocks for Magento 2:

  • In the Master Import Table for Magento 2 – a Google Sheet table where we have gathered sample tables with every Magento 2 entity. Every attribute of every entity comes with a description, explaining how to use this attribute, and a sample value to give you a better understanding of how the table works.
  • In the Firebear Studio GitHub. At GitHub, we have gathered sample tables of different formats including CSV, XML, Json, XLSX, and ODS with every Magento 2 entity you can import and export. You can also find other sample files with XSLT templates and a readme file explaining how everything works.

Alternatively, if you have already installed the Improved Import and Export extension you can try exporting the static blocks you already have at your Magento 2.

How to Export Static (CMS) Blocks from Magento 2

Once installed, the Improved Import and Export extension introduces its sections under System > Improved Import/Export. There you can get access to the import and export jobs – a basic set of settings that let you perform manual or automatic import or export of required entities, in a required file format, on set conditions.

If you proceed to System > Improved Import/Export > Export jobs you will see an export job grid where you can create new jobs and manage existing jobs.

Magento 2 Static Blocks: export jobs

The export job grid comes with a set of filters and mass actions just as every other Magento 2 grid.

To create a new job click the ‘Add New Job’ button.

Magento 2 Static Blocks: general settings

In the General Settings of the export job, you are suggested to specify the job name and set the job schedule to export static blocks from Magento 2 automatically.

Magento 2 Static Blocks: export settings

Below the General Settings, you will find Export settings. Here you decide which entity you want to export, in this article, we will be exporting CMS blocks; however, there are more entities available, including CategoriesCart price rulesCMS pages, etc.

You can also set up a Consecutive Export – if it is enabled and the export job is set to run automatically, every consecutive execution of the job will export NEW entities, that have been created in Magento 2 since the last execution of the job.

For example, if you are running the export jobs every week, the consecutive jobs will let you export only the entities that you have created in your Magento 2 store the last week.

Magento 2 Static Blocks: file format and source

In the Export Behavior, you decide on the file format you want to export the data into and set the export file separator values.

Magento 2 static blocks: export source

In the Export Source configuration section, you select the export source for your Magento 2 static blocks:

  • File;
  • Dropbox;
  • FTP;
  • SFTP;
  • URL.

And specify the path to the file where the data should be exported. The files are created automatically and can be downloaded right from the export job screen after the export is complete.

There are also other settings available in the export jobs, such as attribute mapping and filters. You can find a description of all these settings in the Improved Import and Export extension Manual.

Once you are done with the export job settings, click the ‘Save & Run’ button and execute the job. The static blocks will be exported from Magento 2.

Magento 2 Static Block Attributes

This part of our Magento static blocks tutorial is the most important because it reveals what attributes are used in a CSV file with static blocks. Below, explain all these attributes and corresponding values. For reference, follow the Static Blocks sample table from the Google Master Import table.

Attribute Name Reference Values Value Example
block_id Unique Static Block ID In the administrator panel, can be found in the link of the static block preferences page. For example:

/index.php/admin/cms/block/edit/block_id/19/

Where ‘19‘ is the block ID.

13
content Content of the static block Can contain any symbols and references. Just as when you create and edit a static block. <p>Content of the <strong>custom static block #1</strong>.</p>

<p>&nbsp;</p>

creation_time The time the static block has been created Only the following date format is allowed:

YYYY-MM-DD HH:MM:SS

2/10/2019 7:29:55
identifier REQUIRED FIELD TO CREATE A BLOCK
Static block ‘Identifier’. A unique name of the static block that is used as a reference for internal purposes.
Can be up to 64 Latin characters in length, without spaces, and can contain “-” and “_”. custom-block-1
is_active ‘Enable Block’ setting of the static block. Defines if the block is enabled or disabled. Allowed values:

1 – enabled

0 – disabled

1
title REQUIRED FIELD TO CREATE A BLOCK
‘Block Title’ of the static block. Can contain any value. A name of the static block.
Can contain any value. A name of the static block. Custom static block #1
update_time The time the static block has been last updated Only the following date format is allowed:

YYYY-MM-DD HH:MM:SS

2/10/2019 7:29:55
store_view_code REQUIRED FIELD TO CREATE A BLOCK
The code of the store view the static block belongs to.
Can contain multiple store view codes separated by commas without spaces.

Store View Code can be found under Stores > All Stores. Next, click the required store view and check the “Code” column.

Store View 1,Store View 2,German Store

NOTE: you can export and import blocks composed with Magento 2 Page Builder. The corresponding content is stored in the ‘content’ column. You can also edit it manually if required.

That’s it, these are all the static block attributes that can be exported, edited, and imported to Magento 2.

How to Import Static Blocks to Magento 2

You can import Magento 2 static blocks with the Improved Import and Export extension as follows:

  1. Proceed to System > Improved Import/Export > Import jobs screen to find the import grid.
    Magento 2 static blocks: import job
  2. The import grid offers the same functionality as the export grid. You can filter already created jobs, edit the jobs directly from the grid, or create new jobs. Create a new job by clicking the ‘Add New Job’ button.
  3. In the General Settings of the job, you are suggested specifying the job name, schedule, and other settings that can be found in the Improved Import and Export manual.
    Magento 2 static blocks: general settings
  4. In the Import Settings, choose CMS blocks as your Magento 2 import entity.
    Magento 2 static blocks: import settings
  5. In the Import Behavior, specify how the extension should treat Magento 2 CMS blocks in the table you are about to upload:
    – Add/Update – new entities will be added to the existing ones, if entities with the same ID and identifier already exist, such entities will be updated;
    – Replace – entities with the same ID and identifier will be replaced;
    – Delete – entities from the imported table will be removed from the store.
    Along with the behavior, you control the allowed error count and can map separators.
    Magento 2 static blocks: import behavior
  6. In the Import Source section, specify the format of the file with Magento 2 static blocks: CSV, XML, Json, XLSX, and ODS. Specify the import source: File, FTP/SFTP, Dropbox, Direct URL, or Google Sheets.
    Magento 2 static blocks: import file type and source
  7. When the table you are importing is uploaded, hit the ‘Validate file’ button and let the extension check the file for proper data format.
  8. Next, click the ‘Save & Run’ button and execute the import job.

There are other settings available for import jobs. You can learn more about them in the Improved Import and Export user guide.

Magento 2 CMS Block Import FAQ

Below, we provide answers to questions that Magento 2 users often ask when it comes to the benefits of CMS block import with the Improved Import & Export Magento 2 extension.

How to import CMS blocks to Magento 2 automatically?

If you need to transfer CMS blocks to Magento 2 regularly, it is necessary to install a third-party tool. Unfortunately, the default import/export solutions don’t let you create import jobs that run on schedule. Therefore, we recommend you use the Improved Import & Export extension to import CMS blocks to Magento 2 automatically. The extension leverages cron so that you can create a schedule of updates. Next, the module does everything for you.

How to import Magento 2 static blocks from external systems?

While the default Magento 2 import mechanisms block the import of third-party data that doesn’t follow the system’s requirements, you can use the Improved Import & Export extension to circumvent these restrictions. The module lets you create a mapping scheme matching any external values to the default Magento 2 attributes. Consequently, any external data is easily adapted to the native standards of your e-commerce website. The most intriguing aspect is that you do everything right in your admin.

How to import Magento 2 static blocks via API?

You need to use the Improved Import & Export Magento 2 extension to import CMS blocks to Magento 2 via API. Our extension lets you create the connection between the two systems transferring any data, including CMS blocks. Any import job provides an interface where you can specify the parameters necessary to put the two systems together.

How to import CMS blocks to Magento 2 via ODS files?

If the CMS block data is stored in an ODS file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import ODS files to your ecommerce website without any necessity to run the conversion.

How to import Magento 2 static blocks via XLSX files?

If the CMS block data is stored in an XLSX file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import XLSX files to your ecommerce website without any necessity to run the conversion.

How to import CMS blocks to Magento 2 via JSON files?

If the CMS block data is stored in an ODS file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import JSON files to your ecommerce website without any necessity to run the conversion.

How to import Magento 2 static blocks as compressed files?

If the CMS block data is stored in a compressed file, you can also transfer it to Magento 2 with the help of the Improved Import & Export extension. However, there are two requirements to follow. Firstly, your file archive should be in a ZIP or TAR format. Secondly, the compressed data should be stored in a CSV, XML, ODS, XLSX, or JSON file.

How to import Magento 2 CMS static blocks from Google Sheets?

If your CMS blocks are stored in Google Sheets, it is no longer a problem. There is no need to export it from the service and then transfer the output to Magento 2. The Improved Import & Export lets you move the corresponding information straight from Google Sheets to your e-commerce website. It is only necessary to specify the address of the corresponding data table.

How to import CMS blocks to Magento 2 from Dropbox?

In addition to Google Sheets, the Improved Import & Export module lets you transfer CMS blocks to Magento 2 from Dropbox. Your data should be stored in CSV, XML, ODS, XLSX, or JSON. If it is a compressed file, it should be in a ZIP or TAR format.

How to import Magento 2 static blocks from Google Drive?

In addition to Google Sheets and Dropbox, the Improved Import & Export module lets you transfer CMS blocks to Magento 2 from Google Drive. Your data should be stored in CSV, XML, ODS, XLSX, or JSON. If it is a compressed file, it should be in a ZIP or TAR format.

How to export CMS blocks from Magento 2

You can also export CMS blocks from Magento 2 with the help of the Improved Import & Export extension. Ask our specialists for further information.

Final Words

As you can see, Magento 2 static blocks are easy to create and manage. You can also import and export them if necessary following this Magento static blocks tutorial. If you require further assistance or have any questions – don’t hesitate to contact us. Follow this link to get our Magento 2 importer:

Get Improved Import and Export Extension