Product Attachments
Module: Magenx_ProductAttachments · storefront flag features.productAttachments
Attach files to a product: manuals, data sheets, care instructions, certificates. Upload them on the product edit page, or link to a file hosted elsewhere. They can be attached to the sales emails Magento sends, and listed as downloads on the product page. The browser never sees where a file really lives.

Add attachments
Section titled “Add attachments”- Enable Stores > Configuration > Magenx > Product Attachments > Enabled.
- Open Catalog > Products, edit a product, and find the Product Attachments section.
- Upload files, then save the product. Each new file becomes a row, titled after its file name.
- In the Attachments grid, change titles and sort order. To link an external file, click Add Attachment, set Type to External Link, and enter a title and an
http(s)URL. - To remove an attachment, delete its row and save. An uploaded file is deleted with its row.
Where attachments appear
Section titled “Where attachments appear”Sales emails. Uploaded files of every product in an order are attached to the emails chosen in Attach To (order, invoice, shipment, credit memo).
- External links are never mailed. A slow external host must not delay an order confirmation.
- Order comment and update emails never carry attachments. They are sent many times over an order’s life.
- A missing, oversized or unreadable file is skipped and logged. The email is still sent.
Product page. With Show On Product Page on, the product page lists its attachments as download chips. This setting is separate from Enabled: you can email files without publishing them, or the reverse.
The storefront fetches the file and streams it, so the browser only ever sees /api/download/<id>. An attachment is only served when its product page is itself public on that store.
Safety
Section titled “Safety”- Executable and script file types (
php,phtml,phar,sh,exe,js,html,svg,xmland similar) are always refused, whatever Allowed Extensions says. - The file type is read from the file’s content, not its name.
- External links must be absolute
http(s)URLs. - Anyone who may edit the product may attach files to it.
User flows
Section titled “User flows”Attach files
- With the feature on, the product edit screen shows an attachments section.
- The manager uploads files; each is stored immediately in the product's folder.
- On product save, each new file becomes an attachment titled after its file name.
- Titles and order are edited in a list; external links can be added with title and address.
- Removing an attachment and saving deletes it, and its file for uploads.
SKU renamed
- The product's folder moves and every upload follows.
- A customer orders products with uploads.
- The selected emails carry those files, within count and size budgets.
- Missing, too large or unreadable files are skipped and logged; the email still goes. External links are never emailed; order update emails never carry files.
Download from the product page
- With product-page display on, the product returns attachment details (id, title, type, extension, file type, size).
- The shopper clicks one; the storefront's download route calls the server-only lookup with the id.
- If the attachment's product is public in the store view, the lookup returns the location; the route fetches and streams the file.
These always hold:
- No stored path points outside the attachments area.
- No executable or active type is ever stored.
- The product details never contain a usable location.
- An attachment problem never prevents an order email.
- The download lookup reveals nothing a visitor of public product pages could not see.
- Files in an email = uploads of ordered products in their order, until the count or total size is reached.
Edge cases
Section titled “Edge cases”| Situation | What happens |
|---|---|
SKU containing ../. | Folder name cleaned, stays inside the area. |
| Script disguised with a document extension. | Refused by content check. |
External link javascript:…. | Refused on save and on lookup. |
| Upload's file missing on disk. | Skipped in email; logged. |
| 15 files of 3 MB on one order. | Files within 20 MB / 10 attached; rest skipped; email sent. |
| Download id of a disabled product. | Empty. |
| Download id of a product not sold on this website. | Empty. |
| Feature off. | No section; uploads refused. |
Who it applies to
Section titled “Who it applies to”- Any product; storefront display only for public products.
Out of scope
Section titled “Out of scope”- Attachments on categories, content pages or orders.
- Downloads restricted to buyers or customer groups.
- Emailing external links, or fetching external files in the back office.
- Versioning or download statistics.
Install
Section titled “Install”composer require magenxcommerce/module-product-attachmentsbin/magento module:enable Magenx_ProductAttachmentsbin/magento setup:upgradebin/magento setup:di:compile # production mode onlybin/magento cache:flush- PHP
~8.4.0||~8.5.0, Magento 2.4.8.
Configuration
Section titled “Configuration”Stores > Configuration > Magenx > Product Attachments
General
| Setting | Default | Scope | Notes |
|---|---|---|---|
Enabledmagenx_product_attachments/ | No | Store view | Yes/No. Master switch. Off by default: the Product Attachments fieldset is absent from the product edit page, uploads are refused, and no email carries attachments. Files already in the media folder are left untouched. |
Media Directorymagenx_product_attachments/ | product_attachments | Global | Text. Folder under pub/media holding one sub-folder per product, named after the product SKU (or its numeric id). Files dropped there by hand are picked up exactly like uploaded ones. One path segment: letters, digits, dot, dash, underscore. |
Attach Tomagenx_product_attachments/ | order | Store view | Multiple select. Shown when Enabled = Yes. Which sales email carries the files. Order comment/update emails are never attached to, only the emails selected here. |
Show On Product Pagemagenx_product_attachments/ | No | Store view | Yes/No. Independent of Enabled above: lists this product's attachments (uploaded files and external links) as downloadable chips on its storefront page, between Product Features and Product Description. Off by default — a merchant can mail attachments without publishing them, or the reverse. |
Limits
| Setting | Default | Scope | Notes |
|---|---|---|---|
Allowed Extensionsmagenx_product_attachments/ | pdf,doc,docx,xls,xlsx,csv,txt,rtf,odt,ods,zip,jpg,jpeg,png,gif,webp | Global | Text. Comma-separated, no dots. Applies to uploads AND to files dropped in by hand — anything else in the folder is ignored, never mailed. Executable types (php, phtml, sh, exe, …) are always refused whatever is listed here. |
Maximum File Size (bytes)magenx_product_attachments/ | 10485760 | Global | Text. Per file, on upload and on attach. Default 10485760 (10 MB). A larger file already in the folder is skipped and logged. |
Maximum Total Size Per Email (bytes)magenx_product_attachments/ | 20971520 | Store view | Text. Shown when magenx_product_attachments/general/enabled = Yes. Default 20971520 (20 MB). Most mail servers reject more; files past the budget are skipped and logged rather than the email failing. |
Maximum Files Per Emailmagenx_product_attachments/ | 10 | Store view | Text. Shown when magenx_product_attachments/general/enabled = Yes. Default 10. An order of many products can otherwise mail dozens of files. |
Admin permissions
Section titled “Admin permissions”Grant these under System > Permissions > User Roles > Role Resources:
| Resource | Under | ID |
|---|---|---|
| Product Attachments Settings | Stores > Settings > Configuration | Magenx_ProductAttachments::config |
GraphQL
Section titled “GraphQL”ProductInterface.attachments lists titles, types, sizes and MIME types, never a location. productAttachmentDownload returns the location and is meant only for the storefront server. It is kept off the browser allowlist.
Queries
productAttachmentDownload(id: Int!): ProductAttachmentDownloadSERVER-ONLY: resolves an attachment id to its actual, fetchable location. Intended to be called only server-to-server by the storefront's /api/download/[id] route, never from a browser. Do NOT add to a persisted-query allowlist.
| Argument | Type | Description |
|---|---|---|
id | Int! | The attachment id from ProductAttachment.id. |
Fields added to Magento types
| Field | Type | Description |
|---|---|---|
ProductInterface.attachments | [ProductAttachment] | This product's downloadable attachments (uploaded files and external links), ordered for display. Null when the feature or its storefront toggle is off, or the product has none. |
Types
type ProductAttachment - One product attachment's metadata — never its real file path or external URL. Download it via productAttachmentDownload(id: ...).
| Field | Type | Description |
|---|---|---|
id | Int! | Opaque attachment id. Pass it to /api/download/[id] on the storefront (or, server-to-server, to productAttachmentDownload) to fetch the file. |
title | String! | Display label. |
type | String! | upload or external. |
file_extension | String | Lowercased file extension without the dot, when known — e.g. pdf. |
mime_type | String | MIME type, when known. |
size | Int | Size in bytes, when known. Null for an external link until it has been downloaded once. |
type ProductAttachmentDownload - Result of productAttachmentDownload — the real, otherwise-hidden location of one attachment.
| Field | Type | Description |
|---|---|---|
type | String! | upload or external. |
file_url | String! | The actual URL to fetch the bytes from — a pub/media URL for an upload, the merchant-entered URL for an external link. Never expose this to a browser. |
filename | String! | Suggested filename, with extension, for the Content-Disposition header. |
mime_type | String | MIME type, when known. Falls back to application/octet-stream if null. |
Glossary
Section titled “Glossary”| Term | Meaning |
|---|---|
| Attachment | Product, type, title, order, and either a stored file or an external link. |
| Upload | A file stored in the attachments area, in a folder per product SKU. |
| External link | An absolute http(s) address of a file hosted elsewhere. |
| Attach-to emails | The order emails that carry uploads. |
| Download lookup | Server-only call that turns an attachment id into its real location. |
| Download route | Storefront server route that fetches the file and streams it to the browser. |
| Public product | Enabled, visible in catalog or search, sold on the request's website. |