15 min readNov 22, 2026by jakub
Product Attachments · v1.3.1 · €199Get it on qoliber.com
Changelog
Current version: 1.3.1
All notable changes to the Qoliber Product Attachments module are documented here. The format is based on Keep a Changelog.
[1.3.1] - 2026-11-21
Fixed
- A product save could delete attachments added after the product was loaded,
and undo edits made in the meantime. A product's attachment list replaces
the stored one on save, and the list loaded with the product goes along with
every save: a price import that loaded its products and saved them minutes
later deleted any manual added in between, and wrote back old titles. A save
now applies only what its own code changed, field by field: rows it removed
are deleted, the fields it edited are written onto the row as stored now,
every other field stays as it is, and rows added since it loaded the product
stay. Moving an attachment no longer puts back a title someone else just
fixed. When both changed the same field, the save's own edit is written. The
type and what it points at (link or file) count as one change: a link edit
saved after someone else turned the link into a file used to be dropped while
the save reported success; now the edited link is what is stored. An
empty list removes the attachments the product was loaded with. A list the
caller builds itself (a
PUT /V1/products/{sku}body withproduct_attachments) still replaces all of them. - The same in the admin. An attachment added (by an import, the API or another admin) while the product form was open was deleted when the form was saved, and every row was written back as the form showed it, undoing edits made meanwhile. The form now posts what each row held when it opened: its save removes only rows the merchant deleted, and writes only the fields the merchant changed.
- Saving the same product object twice after adding an attachment (a script, an observer re-saving the product) replaced the new attachment with a copy under a new id, which broke its download link. The second save now updates the same row, also when both saves run in one transaction; after a save that rolled back, the retry creates the attachment once. Within one transaction, each save starts from what the previous one wrote: removing again an attachment the first save added, or putting back a title it changed, is applied too. Only the commit makes it final; a rollback discards it.
- A product save failed with "There is no attachment with provided ID" when its list, or the open product form, still held an attachment someone else had deleted. That attachment now stays deleted and the save goes through.
- An incomplete or malformed product form post could delete attachments. Rows
that are not a list of rows deleted every attachment of the product; a post
carrying
product_attachmentswithout the panel's marker either deleted all of them (no rows) or every row it left out; an empty row among the rows was dropped, so a post of one malformed row removed everything. Rows were also checked only while they were built, so an earlier row's upload had already been moved when a later row was refused. Now every row is checked completely before the first one is built: malformed or empty rows, malformed ids, an upload no longer in the upload folder, a new or changed link that is not valid, and a panel post without what its rows held stop the save with an error, and no upload is moved. Rows posted without the marker are added or updated and delete nothing. - Malformed attachment ids (
1e30,1.5,"-3", digits beyond the integer range) were cast to some other attachment's id, and raised a warning on PHP 8.5 before anything could refuse them. They are now refused with "Attachment ID is not valid" before any row or file is touched.
Performance
ProductRepository::getList()(GET /V1/productsand every integration that pages through the catalog) read each product's attachments with a query of its own, plus one for the store views of those it had, also for products without attachments. The attachments of the whole page are now read at once: two queries for every 500 products of a store view, instead of up to two per product.
Upgrade notes
- A product edit page opened before the upgrade cannot be saved after it: the save stops with "The attachments on this form no longer match the product" and changes nothing. Reload the page and save again.
- The list read for
getList()comes from two new plugins. Runsetup:upgradeandsetup:di:compileas for any upgrade; on Mage-OS with compiled interceptors, plugins take effect only once generated code is rebuilt.
Compatibility
AttachmentInterfacestays as 1.3.0 shipped it, withgetStoreIds()andsetStoreIds(). A class of your own that implements the interface directly (rather than extendingModel\Attachment) needs these two methods since 1.3.0; removing them again would break code written against 1.3.0.
[1.3.0] - 2026-11-03
Added
- Attachments can be limited to store views. Each row on the product form has a Store Views column (default: All Store Views), so a product can carry a manual per language and each store view shows only its own: the product page (Luma and Hyvä), "My Attachments" and the download URL all follow it. A link to an attachment opened on a store view it is not assigned to is refused like one to a disabled product. The column is read-only in a store-view scope and hidden in single-store mode.
AttachmentInterface::getStoreIds()/setStoreIds()(store_idsin REST, 0 for All Store Views). Left out (null), an update keeps the stored store views and a new attachment shows in all of them; an empty list or an unknown store view is refused. Implementations of the interface outside this module need the two methods.Collection::addStoreFilter(), andModel\Attachment\StoreVisibilityfor code that lists attachments itself.
Changed
setup:upgradeassigns every existing attachment to All Store Views (new tableqoliber_product_attachments_store), so storefronts look as before. An attachment written straight intoqoliber_product_attachmentsby an import also needs a row there, or it shows nowhere.- Deleting a store view removes it from every attachment; one assigned to that store view only then shows nowhere, rather than everywhere.
[1.2.0] - 2026-10-29
Security
- An attachment could publish any file under
pub/media. The stored file path is the caller's: through the API, anattachment_filepointing outside the attachment folder served another media file, such as a paid downloadable link file, through the public attachment URL, and the admin form's posted path moved files out of any media folder. Stored paths must now have the shape an upload stores (/a/b/name.ext), and a new upload an allowed extension; a stored path that does not is not served. - A download's
Content-Typewas sniffed from the file's content and the file was shown inline by default: an HTML file uploaded asdatasheet.pdfran its scripts on the store's own domain, and in the admin preview with the admin's session. The type now comes from the extension, withX-Content-Type-Options: nosniff; only PDF, text and images are ever shown inline, and the admin preview always downloads. - Uploads (admin and API) accept only the extensions in the new Allowed file extensions setting; before, anything not on Magento's protected list went through. Files 1.1.x already stored keep working whatever their type: they download, and "Save & Duplicate" copies them.
- The product page's section heading on Luma (the
attachments_titleproduct attribute) was printed without escaping: Luma's tab template prints titles as they are. 1.2.0 escapes it in the block. (The earlier entry below covered attachment titles and product names only.) - A replaced file, and the file of a deleted attachment, stayed in
pub/media/downloadable/files/attachmentfor good, downloadable by anyone who had its direct URL. It is deleted once the save is committed and no attachment uses it any more, from database media storage too.
Fixed
- A title longer than 120 characters, or a link longer than 1024, failed the save with an SQL error; both are validated now, in the form and in the repository. A link with control characters in it is refused.
- A link containing spaces or non-ASCII characters redirected to a path on the store's own domain instead of the link: the redirect went through Magento's route builder. It is sent as a plain redirect, percent-encoded, with an IDN host converted.
- A duplicated product showed the original product's attachments until it was reloaded: the per-product attachment cache was copied along with the product data.
- A file missing from the media directory gave a server error on download; it shows the "error getting requested content" message.
- Product pages, and every other request that loads a product, failed on PHP 8.4 and 8.5: the attachment collection still had implicitly nullable constructor parameters, and Magento turns the resulting deprecation into an exception (#1).
- Saving a product without its attachment list deleted all of its attachments. A
REST partial update (
PUT /V1/products/{sku}with, say, a price andwebsite_ids), or code saving a product it loaded from a collection, wiped them. A missing list now leaves the attachments alone; an empty list still removes them. - Saving a product with attachments through
ProductRepositoryInterfaceafter loading it failed with "The product was unable to be saved": the attachment collection was cached under the extension attribute's own data key, which the repository overwrites. - Every save of the product edit form recreated every attachment under a new id,
breaking download links already handed out. The form posts the id under
id, and a fieldset mapping replaced it with a never-postedattachment_id. - Replacing the file of an existing attachment in the admin kept the old file: the repository wrote the stored path back over the uploaded replacement.
- A virtual product, or a simple product without weight, became a downloadable
product as soon as it was saved with an attachment. The form posted its rows
under the
downloadablerequest key, which Magento_Downloadable reads as "make this downloadable". Rows are now posted underproduct_attachments, and the observer that patched the type back for bundle and grouped products is gone. For products 1.1.x already converted, seeqoliber:product-attachments:restore-product-typesbelow. - Attachment titles and product names rendered as raw HTML on the product page and the account page, Luma and Hyvä alike. Markup in a title ran on the storefront.
- Store-view titles: saving a product in a store-view scope copied every attachment title into that store view, so later changes to the default title never reached it; an attachment created in a store-view scope had no default title and showed untitled everywhere else; a later default-scope save could delete the store-view titles. Rows now have a "Use Default Value" checkbox in store-view scope. A product save writes titles to the product's own store, not to whichever store happens to be current (a CLI or cron job saving a product loaded for store 2 used to write store-1 titles; the admin's store 0 turned store-view titles into default ones).
- Attachments that 1.1.x left with a store-view title only get it as their
default title (data patch
BackfillDefaultAttachmentTitles), so other store views no longer show them untitled. On a fresh install the patch has nothing to do, also whensetup:upgrade --keep-generatedreaches it before Magento has created the module's tables. - Product-page and account-page attachments ignored their sort order. A sort order of 0 set in the admin was saved as 1, tying the row with the next one.
AttachmentRepositoryInterface::save()with base64 file content failed with "isInternalStorage() on null" (#2).- A link attachment showed "0 MB" as its size. A file missing from the media directory, or kept on remote storage, made the whole attachments block disappear in production mode and broke the page in developer mode; it now shows no size.
- The admin upload endpoint stored files of an unknown upload type in the publicly
served root of
pub/media; it now refuses them. Its response no longer carries the admin session id. - Turning a link into a file, or the other way round, left the old value behind; a file attachment that used to be a link kept redirecting to the link.
- A new or changed link is validated on update too, not only when created. An
unchanged link is not, so one stored before validation got stricter (an
ftp://URL) does not make every save of its product fail. - A product whose attachment file is missing from the media directory could not be saved from the admin ("Attachment file not provided"); the stored file is kept.
- With database media storage, files uploaded in the admin never reached the database: the upload checked the wrong result key.
- "My Attachments" no longer counts closed (refunded), pending-payment or
payment-review orders as purchases, and no longer lists attachments of products
that are disabled or not in the current website. The excluded order states are
the
excludedOrderStatesargument ofPurchasedItemsAttachmentProvider. - "Open links in new window" used an inline
onclickhandler, which a strict Content Security Policy blocks. Links carrytarget="_blank" rel="noopener". - Saving an attachment through the repository now refreshes the product page in the full page cache.
- Icon-only download links on the product page have an accessible label.
- File-type icons showed the wrong colours: every icon in the sprite defined its
colours as
.st0/.st1in a<style>of its own, but a style block applies to the whole document, so the last one won. PDF icons lost their red, Word icons their blue, and the generic icon its white page. Each icon now carries its own colours. - Link attachments used the generic download icon and the "Start download" label, with nothing saying they open a web page. They have a link icon of their own and are labelled "Open link".
- Translation keys that did not match the strings in the code, including one phrase whose line break kept it from ever matching.
- The product form's data provider used
nullas an array key for a new product, which PHP 8.5 deprecates. - The admin attachments panel drew the "Title" and "File" labels a second time inside the first row, over the column headers.
Changed
- "My Attachments" reads the customer's purchased products in one query. It used to pass the id of every order the customer ever placed into a second query.
- Downloads are sent with
Cache-Control: private, and the session lock is released before the file streams, so a large download no longer blocks the shopper's other requests. - The admin preview route accepts GET only.
- A product save writes only the attachments that changed. Every attachment used to be loaded, updated, re-titled and purged from the cache on every save.
AttachmentRepository::getList()reads titles in the same query instead of two more per attachment.composer.jsonrequiresmagento/module-configandmagento/module-theme, whichsystem.xmland the account page layout use.- Constructor dependencies, for anyone extending these classes:
AttachmentRepository(+StoreManagerInterface),Attachment\UpdateHandler(+SearchCriteriaBuilder),Attachment\Builder(−Copy),ResourceModel\Attachment\Collection(+Eav\Model\Config, second argument),Ui\...\Modifier\Data\Attachments(attachment collection factory instead of the repository, −Escaper),Controller\DownloadProcessor(−Mime, +FileTypes,StoredFilePath,SessionManagerInterface;processDownload()takes an optional$forceDownload),Controller\Download\Attachment(+RedirectFactory),Controller\Adminhtml\Attachment\File\UploadandModel\File\ContentUploader(+FileTypes),AttachmentRepository(+StoredFilePath),Attachment\Builder(+StoredFilePath,FileTypes),ResourceModel\Attachment(+Filesystem,StoredFilePath, the media storageDatabasehelper, before$connectionName) andCustomer\PurchasedItemsAttachmentProvider(− orderCollectionFactory).
Removed
- Dead DI configuration: a type entry for a class that does not exist, an argument no constructor takes, a metadata pool entry naming a table that does not exist, and a registration with Magento_Downloadable's type handler that nothing calls.
Deprecated
DownloadResourceResolver::resolveResource(),::resolveResourceType()andEavAttributeJoiner::join(). None is used by the module.
Added
bin/magento qoliber:product-attachments:restore-product-typesfinds the products 1.1.x turned into downloadable products: downloadable, with attachments, and without a single downloadable link or sample. It only lists them;--applymakes them virtual again (what Magento makes of any product without weight), keeping their attachments, and--skulimits it to chosen products. Run it once after upgrading, check the list, then apply.AttachmentRepository::saveInStore(): save an attachment with its title in a given store.- Allowed file extensions setting (
product_attachments/general/allowed_extensions). Model\File\FileTypes(allowed extensions, content type by extension, which types may be shown inline) andModel\File\StoredFilePath.- Unit and integration tests for the fixes above.
[1.1.1] - 2026-10-20
Changed
composer.jsondeclaressupport.security: https://security.qoliber.com.
[1.1.0] - 2026-07-27
Fixed
- The
Enabledsystem configuration switch now actually gates the module. It had no call sites, so attachments rendered and downloaded regardless of the setting. The shipped default moves from0to1so existing stores keep their current behaviour. - System configuration referenced the ACL resource
Qoliber_ProductAttachments::config, whichacl.xmlnever defined, leaving the section ungrantable to restricted admin roles. It now points atQoliber_ProductAttachments::product_attachments. - The adminhtml attachment preview controller declared no
ADMIN_RESOURCEand so fell back toMagento_Backend::admin, letting any backend user fetch any attachment by id. It now requiresMagento_Catalog::products, matching upload. - A sort order of
0was rejected as "not a positive integer" becausefilter_var()returns a falsyint(0). Zero is valid for an unsigned column. ContentUploadernever populated the parent uploader's validator, so every API-side upload fatally dereferenced null and the protected-extension check never ran. Executable extensions are now refused.- Base64 payloads are decoded in strict mode instead of silently writing corrupt bytes when the input is malformed.
- Attachment downloads verify the owning product is enabled and assigned to the current website. Previously a link kept working after the product was disabled.
Content-Dispositionfile names are escaped, so a stored name containing a quote or a line break can no longer truncate or split the response headers.- URL-type attachments validate the redirect target before sending the visitor.
- Attachments stream to the client in chunks. They were read wholly into memory first, making peak usage scale with the largest file on the store.
- A zero-byte attachment, or one whose contents are exactly
0, no longer reports itself as unreadable. - Cancelled orders no longer grant access to purchased-item attachments, and the listing is scoped to the current website.
- The purchased-items lookup selects ids in two queries instead of hydrating every order and order item the customer has ever placed.
store_idis quoted throughquoteInto()in the title join.- Implicit nullable parameters were made explicit for PHP 8.4 forward compatibility.
Added
- Unit test coverage for attachment validation and download header construction.
db_schema_whitelist.json, absent until now, which the declarative schema needs before it will apply column or constraint removals.created_atandupdated_atonqoliber_product_attachments.- A unique key on
(attachment_id, store_id)in the title table, plus a foreign key tostore. Title writes useinsertOnDuplicateso concurrent saves cannot violate it.
Changed
attachment_urlwidened from 255 to 1024 characters.qoliber_product_attachments_title.store_idis nowsmallint unsignedto matchstore.store_id, which the new foreign key requires.
Upgrade notes
-
The new unique key on
(attachment_id, store_id)will fail to apply if the table already holds duplicate rows for a pair. Remove them before upgrading:SQLDELETE t1 FROM qoliber_product_attachments_title t1 INNER JOIN qoliber_product_attachments_title t2 WHERE t1.title_id > t2.title_id AND t1.attachment_id = t2.attachment_id AND t1.store_id = t2.store_id; -
Hyvä support moved to the separate
qoliber/product-attachments-hyvapackage. Stores running a Hyvä theme must require it explicitly, otherwise the attachment tab and the account attachment list fall back to the Luma templates.
Removed
- Hyvä layout handles and templates, now shipped by
qoliber/product-attachments-hyva.
[1.0.1] - 2025-05-14
Fixed
- Code quality improvements with PHPStan and PHPCS fixes
- Styling improvements for both Hyva and Luma themes
- Frontend code optimizations
[1.0.0] - 2025-04-30
Added
- Initial release of Product Attachments module
- Complete product attachment management system integrated into product edit form
- File attachment functionality with dual modes:
- File upload: Direct file upload to server storage
- URL attachment: Link to external files or resources
- Multi-store title support for attachments:
- Store-specific attachment titles
- Title localization per store view
- Product edit form integration:
- Attachment panel in product form
- Drag-and-drop file upload
- Sort order management
- Attachment type selection (file/URL)
- Frontend attachment display:
- Product detail page attachment tab
- Downloadable file links with security
- SVG icon sprite for file type indicators
- Attachment title display
- Customer dashboard integration:
- "My Product Attachments" section in customer account
- List of purchased product attachments
- Attachment access based on purchase history
- Dedicated customer account page for attachment downloads
- Security features:
- Attachment ID obfuscation for secure downloads
- Purchase validation before download access
- Resource resolver for download authorization
- Hyva theme support:
- Alpine.js-enhanced attachment display
- Hyva-specific product view tab
- Hyva customer account templates
- Responsive attachment section styling
- Luma theme support:
- Standard product tab integration
- Luma customer account templates
- Compatible with default Magento styling
- Admin functionality:
- File uploader component with preview
- File upload controller with validation
- File preview functionality for admin users
- Database schema:
- Attachment table with product foreign key
- Attachment title table with store view support
- Cascade delete on product removal
- Sort order for attachment display sequence
- UI data providers:
- Product form modifier for attachment panel
- Composite modifier for attachment data processing
- Attachment data builder for form population
- Attachment type handlers:
- File type handler for uploaded files
- URL type handler for external links
- API interfaces:
- AttachmentRepositoryInterface for CRUD operations
- ConfigInterface for module configuration
- ContentUploaderInterface for file uploads
- PurchasedItemsAttachmentProviderInterface for customer access
- Validators:
- Content validation for file uploads
- Attachment type validation
- Observers:
- Type conversion prevention for attachment products
- Plugins:
- InitForSave plugin for attachment data processing
- Service classes:
- URL service for attachment link generation
- Translation support:
- English (en_US) translations
- Polish (pl_PL) translations
- Data patches:
- Product attribute creation for attachments title
- EAV attribute integration for product attachments
- Extension attributes for attachment data in product entity
- Fieldset configuration for data mapping
- ACL permissions for attachment management
- Admin routes for upload and preview
- Frontend routes for download functionality