Skip to content

[Product page] Complimentary product block is fetching the entire product section then deleting it #2065

@gideonb

Description

@gideonb

Describe the current behavior
The fetch call for complimentary products is pulling all of the html for the product section, then deleting everything but the product cards for complimentary products.
https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid#L455

Possible solution
One solution is to extract the inner content of the <product-recommendations> element to a different section and query just the markup you need instead of the full product template.

So the fetch url would be
/recommendations/products?section_id=api-product-complimentary&product_id=1234567&intent=complementary

Instead of
/recommendations/products?section_id=product-main&product_id=1234567&intent=complementary

The difference is section_id=api-product-complimentary instead of section_id={{section.id}}.

The contents of section/api-product-complimentary.liquid are the inner content of the custom element for <product-recommendations>.

Additional context/screenshots
In this screenshot you can see the network request. The content of the complimentary query is highlighted in red. It loads all of the markup for product media, product description, variant selectors, payment buttons, and block content. This is contrasted by the query for the recommendations section below, highlighted in blue.
perf-example-tools
perf_example

Metadata

Metadata

Assignees

No one assigned

    Labels

    Category: Tech DebtOpportunities to refactor or improve the code and/or development workflow

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions