architecture
architecture copied to clipboard
Add Storefront properties for Product Attributes
Problem
PWA-1665 Need to control the use of product attributes on PWA Venia Storefront
Solution
Added a field storefront_properties in the customAttributeMetadata query to expose admin configuration on product attributes related to storefront.
Requested Reviewers
Layered Navigation
Looking at page https://develop.pwa-venia.com/default/venia-dresses.html?page=1, a category page on Venia. The following queries are issued that relate to layered navigation / filters:
Am I correct that the proposal is that we would take the attribute_code, issue a customAttributesMetadata query, and then pull the storefront_properties off of that?
If so, it looks like the customAttributesMetadata query needs more than just the attribute_code, it also wants an entity_type. Acceptable values are catalog_product, catalog_category, or customer. For this query I'm assuming catalog_category.
Product Detail Page
Here's the product details query we send. Here's the fragment.
Looks like we could pull this attribute_code and issue the customAttributesMetadata query with entity_type = catalog_product? We'd use use_in_product_listing and position from there on the PDP.
Category Page
Here's the category query and fragment.
Looks like we'd need to add the attribute_code field and do the additional customAttributesMetadata query with entity_type = catalog_category.
Sorting
We get all the aggregations in the getProductFiltersByCategory query, but we should not rely on the order of the attributes returned from GraphQL for rendering.
It would be ideal to have the ProductInterface expose a field called position (I think you are proposing that but I don't see it here in this PR). Without that, we'd have to send the additional customAttributeMetadata query and pull the position off of storefront_properties. Sort by position and render.
Search
Use in Search
This setting would remain a known bug / unsupported. Attributes are always used in search.
Use in Search Results Layered Navigation
Here's the query for filters for the search page. We could send the attribute_code to customAttributesMetadata to get the storefront_properties but I don't see anything in there for layered navigation specific to search.
Will this remain unsupported as well?
catalog_product
For product attributes it should be catalog_product
Sorting
We get all the aggregations in the getProductFiltersByCategory query, but we should not rely on the order of the attributes returned from GraphQL for rendering.
It would be ideal to have the
ProductInterfaceexpose a field calledposition(I think you are proposing that but I don't see it here in this PR). Without that, we'd have to send the additionalcustomAttributeMetadataquery and pull thepositionoff ofstorefront_properties. Sort bypositionand render.
I will see the feasibility of adding this in the aggregations itself without compromising the backend performance. I should be able to get the answer soon.
Search
Use in Search
This setting would remain a known bug / unsupported. Attributes are always used in search.
Use in Search Results Layered Navigation
Here's the query for filters for the search page. We could send the
attribute_codetocustomAttributesMetadatato get thestorefront_propertiesbut I don't see anything in there for layered navigation specific to search.Will this remain unsupported as well?
we can support both these configurations. Will update the PR.