Repository navigation
Attribute labels and options from documents, and attribute feed freshness - #38
Merged
Merged
Conversation
Core's table source queries the labels per attribute and value (17 on a product page); the attribute documents already carry them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core's attributes view watches eav_attribute and catalog_eav_attribute only, so such a save left the documents stale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core keeps the store labels it read for a worker's life, so a changed label showed only after a restart; the document follows the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core's resync compares option labels only; a configurable's document also copies the attribute's labels and its options' swatches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core queries the swatch table per page and keeps the answer by option id alone for a worker's life, across store views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProductFrontend/Plugin/OptionsFromDocumentsanswersgetAllOptions()andgetSpecificOptions()(and sogetOptionText()) of a product attribute's table source from its attribute document.ProductFrontend/Plugin/StoreLabelFromDocumentsanswersgetStoreLabel()from the document. That covers every attribute label a page shows: the attributes table, the secondary info, the swatches, the sort order and the layered navigation.ProductFrontend/Plugin/SwatchesFromDocumentsanswers core's swatch helper (getSwatchesByOptionsId()) from the attribute documents: the swatches of a product page, of listing cards and of the layered navigation. The helper knows option ids only;AttributeDocuments::optionsById()finds them in the documents the request read, else in every document of the store view, read once. Core's helper keeps the swatches by option id alone for the life of a worker, across store views; the documents follow a change through the attributes feed. ProductFrontend now requires CatalogStorefrontSwatches, which writes the swatches onto the documents.Plugin/Detail/ProductDocumentreads the documents of every attribute of the attribute set in one request.FilterableAttributesFromDocumentsreads every attribute document of the store view once (AttributeDocuments::all(), whichbyCodes()now answers from) and filters the layer in PHP.cde_product_attributes_feedview watches onlyeav_attributeandcatalog_eav_attribute, so a save that changed only labels, options or swatches never reached the documents. This adds triggers on:eav_attribute_labelandeav_attribute_option;eav_attribute_option_value, andeav_attribute_option_swatch(Swatches module), through a lookup from option id to attribute.Model/Mview/LookupSubscriptionfor tables whose rows name no entity of the view; Snowdog'sMenuLookupSubscriptionnow extends it with the same statements.ProductDocument10,OptionsFromDocuments10,StoreLabelFromDocuments10.configurableProductsByChildrenresolver adds their configurables. A configurable'sconfigurableOptionsalso copies the attribute's labels and its options' swatches, which core compares nowhere.ConfigurableProduct/Plugin/Eav/ResyncConfigurablesOnAttributeChange, beside core's resync on the attribute resource'ssave(), compares them before and after a save:threshold(di.xml, default 1000) or a feed not on schedule invalidates the feed, as core does; so does a failure, which is logged. Verified live: a label change re-exported 147 configurables, a swatch change 137 products and their configurables, and a save without changes nothing.Why
Eav\Model\ResourceModel\Entity\Attribute::$storeLabelsCache, andstore_labelson the shared attribute) for the life of a worker. A changed label reached the page only after a restart; the document follows the change through the feed.eav_attribute_option_swatchread), searches unchanged.Verification
MAX_REQUESTS=1: listing 4/4 and detail 6/6 identical.Notes
LookupSubscription: core builds a shared table's trigger with the subscription model of the view that subscribes last.setup:upgradeinstalls the triggers. No new document field, so no rebuild.🤖 Generated with Claude Code
Two Additions are necessary for frankenphp's worker mode:
{ "\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute": { "storeLabelsCache": [] }, "\\Magento\\Swatches\\Helper\\Data": { "swatchesCache": [] } }These will be added to the MageOS WorkerMode package