Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Related Products loader :: remove throw new error and add unavailable items #102

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion functions/vtexLegacyRelatedProductsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export interface Props {
* @description: number of related products
*/
count?: number;
/**
* @description remove unavailable items from result
*/
hideUnavailableItems?: boolean;
}

/**
Expand All @@ -30,13 +34,14 @@ const loaderV0: LoaderFunction<
> = async (
req,
ctx,
{ crossSelling, count },
{ crossSelling, count, hideUnavailableItems },
) => {
const data = await loader(
{
slug: ctx.params.slug,
crossSelling,
count,
hideUnavailableItems,
},
req,
ctx.state,
Expand Down
3 changes: 2 additions & 1 deletion packs/vtex/loaders/legacy/relatedProductsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ async function loader(
const productId = await getProductGroupID(props);

if (!productId) {
throw new Error("Missing props. Please fill: slug or id");
// throw new Error("Missing props. Please fill: slug or id");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// throw new Error("Missing props. Please fill: slug or id");

return null;
}

const vtexRelatedProducts = await fetchAPI<LegacyProduct[]>(
Expand Down