定制 rkd/module-llms-txt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rkd/module-llms-txt

Composer 安装命令:

composer require rkd/module-llms-txt

包简介

Generate llms.txt and llms-full.txt files for Magento 2 stores. Makes your e-commerce catalog discoverable by AI assistants.

README 文档

README

Generate llms.txt and llms-full.txt files for your Magento 2 store, making your product catalog discoverable by AI assistants like ChatGPT, Claude, and Perplexity.

What is llms.txt?

llms.txt is an emerging standard (like robots.txt for search engines) that helps Large Language Models understand your website content. This module automatically generates structured, AI-optimized files from your Magento catalog.

Features

  • llms.txt + llms-full.txt generation (both files, spec-compliant)
  • Inventory-aware output: excludes out-of-stock products (SQL-level filtering)
  • Variant intelligence: configurable product options (color, size), bundle items, grouped products, customizable options
  • Niche-adaptive: admin selects which product attributes to expose (gender for apparel, specs for electronics, ingredients for food)
  • Rich product data: price, SKU, descriptions, custom attributes
  • Category breadcrumbs: hierarchical category paths with product counts
  • Spec validation: checks output against the llms.txt standard
  • Built-in sanitization: HTML entities decoded, whitespace normalized, tables converted to markdown
  • Multi-store & multi-language: one file set per store view with automatic cross-language discovery — each language's llms.txt links to its siblings so AI crawlers find them all
  • Cron-based auto-regeneration with change detection (dirty flags)
  • Manual generation: admin button, CLI command, REST API
  • Robots.txt integration: auto-injects llms.txt references
  • Performance optimized: cursor-based pagination (no OFFSET degradation) + batched EAV queries. Tested on catalogs up to 100K products.

Requirements

  • Magento 2.4.7 or later (tested on 2.4.7-p1 and 2.4.8)
  • PHP 8.1 or later (developed on PHP 8.3)

Installation

Via Composer (recommended)

composer require rkd/module-llms-txt
bin/magento module:enable RKD_LlmsTxt
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Manual Installation

  1. Create app/code/RKD/LlmsTxt/ directory
  2. Copy module files into it
  3. Run:
bin/magento module:enable RKD_LlmsTxt
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Configuration

Navigate to Stores > Configuration > RKD > LLMs.txt Generator

General Settings

Field Description Default
Enable Module Enable/disable the module Yes
Auto-Regeneration Regenerate files on a cron schedule Yes
Regeneration Schedule How often to regenerate Daily
Store Description for AI Describe your store for AI assistants (1-2 sentences) Auto-generated
Generate Now Button to trigger immediate generation

Content Sections

Field Description Default
Include CMS Pages Include CMS pages in output Yes
Include Categories Include product categories Yes
Category Depth Limit Maximum category tree depth 3
Include Products Include products in output Yes
Product Limit Maximum number of products. Set to 0 for unlimited (full catalog). 0 (unlimited)
Product Sort Order How to sort products Best Sellers
Include Store Metadata Include store info section Yes
Exclude Out-of-Stock Filter out unavailable products Yes

Product Data

Field Description Default
Include Prices Show product prices Yes
Include SKU Show product SKU Yes
Include Short Description Show product descriptions Yes
Additional Product Attributes Select extra attributes for your niche

llms-full.txt Settings

Field Description Default
Generate llms-full.txt Generate the complete content file Yes
Max File Size (MB) Size limit for llms-full.txt 5 MB
Content Depth How much detail per product Detailed

Usage

CLI Command

# Generate both files
bin/magento rkd:llmstxt:generate

# Generate for a specific store
bin/magento rkd:llmstxt:generate --store=1

# Preview without writing files
bin/magento rkd:llmstxt:generate --dry-run

# Generate and validate
bin/magento rkd:llmstxt:generate --validate

REST API

POST /V1/rkd/llmstxt/generate    # Trigger generation
GET  /V1/rkd/llmstxt/preview     # Preview output
GET  /V1/rkd/llmstxt/validate    # Validate existing file

URLs

After generation, the files are served at:

  • https://yourstore.com/llms.txt
  • https://yourstore.com/llms-full.txt

Admin Panel

  • Marketing > LLMs.txt > Generate Files — trigger generation
  • Marketing > LLMs.txt > Preview Output — preview without writing
  • Marketing > LLMs.txt > Configuration — module settings

How It Works

  1. SectionProviders collect data from Magento (metadata, CMS pages, categories, products)
  2. Generator orchestrates providers, builds markdown output
  3. Validator checks spec compliance
  4. FileWriter writes to var/rkd_llmstxt/ with atomic writes
  5. Router serves the files at /llms.txt with proper UTF-8 headers
  6. Observers detect entity changes and set dirty flags
  7. Cron checks dirty flags and regenerates when needed

Performance

The module uses cursor-based pagination (WHERE entity_id > :lastId — no OFFSET performance cliff) combined with PHP generators (yield) so each batch is processed and released before the next is loaded. Batch-level memory is bounded; total memory scales with catalog size because the final output is assembled before writing. Write-up of the technique: Paginating Magento catalogs without OFFSET.

Catalog Size Peak Memory Time Recommended PHP memory_limit
1,000 products ~60 MB ~0.2s 256M
10,000 products ~120 MB ~2s 512M (default cap)
100,000 products ~400 MB ~15–20s 1024M (raise product_limit in admin)

By default Product Limit is 0 (unlimited) — the full visible catalog is included. You can optionally cap it via Stores > Configuration > RKD > LLMs.txt > Product Limit (for example, to generate a smaller "top products" file). When a configured cap is hit, the generation result surfaces a clear warning telling you how many products were excluded. For very large catalogs (50K+ products), ensure PHP memory_limit is sized accordingly using the table above.

Multi-Store and Multi-Language Support

Multi-language is a first-class feature, not an afterthought. The module generates one file set per store view and makes every language discoverable by AI crawlers from any entry point.

How it works

For each active store view, the module writes:

  • var/rkd_llmstxt/{store_code}/llms.txt
  • var/rkd_llmstxt/{store_code}/llms-full.txt

…served at the store view's public URL:

URL an AI fetches What it gets
https://example.com/llms.txt Default store view's file (set in Magento's store configuration)
https://example.com/et/llms.txt Estonian store view
https://example.com/ru/llms.txt Russian store view
https://example.com/de/llms.txt German store view

Automatic cross-language discovery

Each file includes an "Available in Other Languages" section listing sibling store views on the same website:

## Available in Other Languages

This store is also available in other language versions. Each language has its own AI-readable catalog:

- [Russian](https://example.com/ru/llms.txt)
- [German](https://example.com/de/llms.txt)

An AI that fetches any one language's llms.txt will find the others automatically — no external sitemap or registry needed.

Language handling internals

Content resolution follows Magento's native EAV store-scope fallback:

  • Product, category, and CMS fields load at the requested store view's scope
  • When a field isn't translated for that store view, the default (admin-scope) value is used — identical to Magento's storefront behavior
  • UTF-8 is preserved end-to-end: Cyrillic, Greek, Chinese, Arabic, emoji, and extended Latin (ä, õ, ß, ü) all render correctly

Note: For AI output to be fully localized per language, merchants should translate product names, descriptions, and attribute values for each store view. If content isn't translated, the fallback (default-scope) value appears — accurate to what the storefront serves, but potentially mixing languages in the output. This is a content-translation responsibility, not a module limitation.

Supported Product Types

Type Output
Simple Name, URL, SKU, Price, Description
Configurable + Available options (Color, Size, etc.)
Bundle + Included items per bundle option
Grouped + Associated products with prices
Virtual + "Digital" label
Downloadable + "Download" label
Customizable Options + Add-on options with prices

Change Detection

The module tracks changes via Magento events:

  • catalog_product_save_after — product changes
  • cataloginventory_stock_item_save_after — stock changes
  • cms_page_save_after — CMS page changes
  • catalog_category_save_after — category changes

When a change is detected, a dirty flag is set. The next cron run regenerates the files.

License

MIT License. See LICENSE.txt.

Support

rkd/module-llms-txt 适用场景与选型建议

rkd/module-llms-txt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「seo」 「e-commerce」 「ai」 「magento2」 「ChatGpt」 「claude」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rkd/module-llms-txt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rkd/module-llms-txt 我们能提供哪些服务?
定制开发 / 二次开发

基于 rkd/module-llms-txt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 37
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-17