Skip to content

Blog

Modules: Magenx_Blog (content and admin) and Magenx_BlogGraphQl (storefront API)

A blog written in the Magento admin and shown by the storefront. Posts can link to related products and related posts, so a product page can show “articles about this product”.

The storefront blog listing
The /blog page on the demo store.

Go to Content > Blog > Posts. A post has these tabs:

  • General: title, URL key, publish date, author, active.
  • Content: the post body in the standard WYSIWYG editor, with the media browser.
  • Categories & Tags.
  • Related Products: a searchable product grid with positions, the same as assigning products to a category.
  • Related Posts.
  • Meta / SEO.
  • Store Views: “All Store Views” or specific ones.

Categories and tags are flat lists, managed under Content > Blog > Categories and Tags.

  • A post with a future publish date stays hidden until that date.
  • Saving a post, category or tag refreshes the storefront’s blog pages right away, through the usual cache invalidation.
  • Post HTML is stored as written. The storefront cleans it before display; any other consumer of the API must do the same.

Write a post

  1. The editor creates a post and fills general data, content (rich text with image picker), categories and tags, related products (searchable grid with positions), related posts, SEO fields and store views.
  2. Saving stores the post and its links and refreshes the storefront's cached blog pages.

Schedule

  1. A future publish date keeps the post hidden on the storefront until then.

Organise

  1. Editors manage categories (with order) and tags (with SEO fields).

Unpublish

  1. Switching a post off or removing its store view hides it on the next request.

Index and filters

  1. The storefront asks for a page of posts, optionally filtered by URL key, category, tag or product SKU (all combined).
  2. It receives the total count and items, newest first.

Post page

  1. The storefront asks for a post by URL key; it gets nothing if the post is not published in the store view.
  2. It renders content (cleaned on display), categories, tags, related posts and related product references.

Tag page and categories

  1. A tag by URL key comes with its published posts.
  2. The category list returns active categories in order.

These always hold:

  • Only published posts are visible outside the admin.
  • URL keys are unique per entity type.
  • A post assigned to "all" and to a specific store view is counted once.
  • Only published posts for the current store view appear anywhere: lists, links, tag pages.
  • Blog off: every operation returns empty.
  • HTML is returned as stored; readers clean it.
  • Page size = min(requested or default, maximum).
  • Page size = min(requested or default, maximum); page ≥ 1.
SituationWhat happens
Post assigned to "all" and to store 1.Listed once in store 1; total count correct.
Publish date tomorrow.Hidden today.
Related product deleted.Link gone.
Duplicate URL key.Save refused with a message.
Blog off for a store view.Nothing shown there; data kept.
A related post is unpublished.Left out of the links.
Unknown URL key.Empty.
Filter by a SKU with no posts.Empty list, total 0.
10-post list asking for every link.One lookup per link type.
  • Store views with the blog on.
  • Public; store view from the request.
  • Comments, likes or ratings.
  • Nested categories.
  • Author accounts, editorial workflow or approvals.
  • Cleaning HTML on save (readers clean it before display).
  • RSS feeds and sitemap entries.
  • Writing content through the API.
  • Full product data inside posts (product references only; the storefront loads products itself).
  • Full-text search of posts.
Terminal window
composer require magenxcommerce/module-blog magenxcommerce/module-blog-graph-ql
bin/magento module:enable Magenx_Blog Magenx_BlogGraphQl
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush
  • PHP ~8.4.0||~8.5.0, Magento 2.4.8.

Installing only Magenx_Blog gives you the admin and nothing on the storefront.

Stores > Configuration > Magenx > Blog

General

SettingDefaultScopeNotes
Enable Blog
magenx_blog/general/enabled
YesStore viewYes/No. When set to No the blogPosts / blogPost / blogTag / blogCategories GraphQL queries resolve to empty results for this store, without removing any data.
Posts Per Page
magenx_blog/general/posts_per_page
10Store viewText. Shown when Enable Blog = Yes. Page size used by blogPosts when the query does not pass pageSize.
Maximum Page Size
magenx_blog/general/max_page_size
50Store viewText. Shown when Enable Blog = Yes. Upper bound on the pageSize a blogPosts query may request; larger values are clamped to this. Guards against a single query loading the whole post table.

With Enable Blog set to No, the blog queries return empty results for that store. No content is deleted.

  • Content > Blog > Posts
  • Content > Blog > Categories
  • Content > Blog > Tags

Grant these under System > Permissions > User Roles > Role Resources:

ResourceUnderID
BlogContentMagenx_Blog::blog
PostsContent > BlogMagenx_Blog::post
CategoriesContent > BlogMagenx_Blog::category
TagsContent > BlogMagenx_Blog::tag
Blog SectionStores > Settings > ConfigurationMagenx_Blog::config

blogPosts can be filtered by URL key, category, tag or product SKU. The related categories, tags, products and posts of a page of posts are loaded together, not one post at a time. BlogPost.products returns SKU and URL-key references; load full product data through the storefront’s product queries.

Post image is a host-less media path such as /media/blog/hero.jpg, served by the storefront’s own /media route.

Queries

blogPosts(filter: BlogPostFilterInput, pageSize: Int, currentPage: Int): BlogPosts

A paginated, filterable list of published blog posts for the current store, newest first.

ArgumentTypeDescription
filterBlogPostFilterInputServer-side filters: url_key, category_id, tag_id and sku are all resolved in the database, not scanned client-side.
pageSizeIntNumber of posts to return. Defaults to 10.
currentPageIntPage number, starting at 1. Defaults to 1.
blogPost(urlKey: String!): BlogPost

A single published blog post by URL key, or null when it does not exist, is disabled, is not assigned to the current store, or is future-dated.

ArgumentTypeDescription
urlKeyString!The post's URL key.
blogTag(urlKey: String!): BlogTag

A single blog tag by URL key, with the published posts assigned to it, or null when it does not exist.

ArgumentTypeDescription
urlKeyString!The tag's URL key.
blogCategories: [BlogPostCategory!]!

Every active blog category, ordered by position.

Types

input BlogPostFilterInput - Server-side filters for blogPosts. All provided fields are combined with AND.
FieldTypeDescription
url_keyStringExact URL key match.
category_idIntOnly posts assigned to this category.
tag_idIntOnly posts assigned to this tag.
skuStringOnly posts with this product SKU in their related products — the "articles about this product" lookup.
type BlogPosts - A page of blog posts.
FieldTypeDescription
total_countIntThe total number of posts matching the query, across all pages.
items[BlogPost!]!The posts on this page.
type BlogPost - A blog post.
FieldTypeDescription
post_idInt!The post's unique ID.
nameString!The post title.
short_descriptionStringA short summary shown on listing cards.
post_contentStringThe full post body, authored in the admin WYSIWYG and returned as HTML exactly as stored. Nothing is sanitized server-side; the Next.js storefront runs it through sanitizeCmsHtml on read, and any other consumer must sanitize before rendering.
imageStringThe headline image as a media path rooted at the store's media base — "/media/blog/hero.jpg", exactly as the admin media gallery inserted it — or null when none is set. Deliberately host-less: in a headless setup the storefront serves media from its own /media route, not from the Magento host.
url_keyString!The URL key used to build the post's storefront URL.
publish_dateStringThe publish date, or null when unset.
author_nameStringThe display name of the post's author, or null when unset.
meta_titleStringSEO meta title, or null when unset.
meta_descriptionStringSEO meta description, or null when unset.
meta_keywordsStringSEO meta keywords, or null when unset.
categoriesBlogPostCategoriesThe categories this post is assigned to.
tagsBlogTagsThe tags assigned to this post.
productsBlogPostProductsThe products related to this post (admin-managed), ordered by their configured position.
postsBlogPostsOther posts related to this post (admin-managed), ordered by their configured position.
type BlogPostCategories - A post's assigned categories.
FieldTypeDescription
items[BlogPostCategory!]!
type BlogPostCategory - A blog category.
FieldTypeDescription
category_idInt!The category's unique ID.
nameString!The category name.
url_keyString!The URL key used to build the category's storefront URL.
type BlogTags - A post's assigned tags.
FieldTypeDescription
items[BlogTag!]!
type BlogTag - A blog tag.
FieldTypeDescription
tag_idInt!The tag's unique ID.
nameString!The tag name.
url_keyString!The URL key used to build the tag's storefront URL.
descriptionStringA description of the tag, or null when unset.
meta_titleStringSEO meta title, or null when unset.
meta_descriptionStringSEO meta description, or null when unset.
postsBlogPostsThe published posts assigned to this tag.
type BlogPostProducts - A post's related products.
FieldTypeDescription
items[BlogPostProductRef!]!
type BlogPostProductRef - A lightweight reference to a related product. Resolve full catalog data via the storefront's own product-by-SKU lookup when display data is needed.
FieldTypeDescription
entity_idIntThe product's entity ID.
skuString!The product SKU.
url_keyStringThe product's URL key, or null when it has none configured.
TermMeaning
PostTitle, short description, HTML content, headline image, URL key, publish date, active flag, author name, meta title / description / keywords.
PublishedActive, assigned to the store view (or to all), publish date not in the future.
CategoryFlat named group with URL key, active flag and position.
TagLabel with URL key, description and meta fields.
Related productA product linked to a post, with a position.
Related postAnother post linked to a post, with a position.
All store viewsAssignment that makes a post visible everywhere.
URL keyUnique slug within its entity type.
Product referenceProduct id, SKU and URL key.
Relative image pathImage path without a host, served by the storefront.