magento / architecture

A place where Magento architectural discussions happen
274 stars 154 forks source link

Add Storefront properties for Product Attributes #490

Open prabhuram93 opened 3 years ago

prabhuram93 commented 3 years ago

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

supernova-at commented 3 years ago

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:

  1. getProductFiltersByCategory
  2. getFilterInputsForCategory

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.

supernova-at commented 3 years ago

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.

supernova-at commented 3 years ago

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.

supernova-at commented 3 years ago

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.

supernova-at commented 3 years ago

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?

prabhuram93 commented 3 years ago

catalog_product

For product attributes it should be catalog_product

prabhuram93 commented 3 years ago

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.

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.

prabhuram93 commented 3 years ago

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?

we can support both these configurations. Will update the PR.