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

Quantidade de produtos por página #701

Open
EliasGabriel1 opened this issue Mar 30, 2023 · 0 comments
Open

Quantidade de produtos por página #701

EliasGabriel1 opened this issue Mar 30, 2023 · 0 comments

Comments

@EliasGabriel1
Copy link

PT

Bem, eu a um tempo atrás estive tentando fazer um filtro de produtos por páginas, procurei nas doc da vtex e não encontrei, vi opções mas sempre envolvia clonar todo o projeto, e acabei encontrando uma forma bem simples com uma função da vtex (searchPageContext.searchQuery.refetch), pode ser algo obvio para alguns, mas pra mim se eu tivesse encontrado algo sobre nas doc pra fazer somente isso sem ser um custom paginator inteiro

EN

Well, a while ago I was trying to filter products by page, I looked in the vtex docs and couldn’t find them, I saw options but it always involved cloning the entire project, and I ended up finding a very simple way with a vtex function (searchPageContext .searchQuery.refetch), might be obvious to some, but for me if I had found something in the doc to do just that without being a whole custom paginator

código (code):

import React from 'react';
import { useSearchPage } from "vtex.search-page-context/SearchPageContext";

const FilterProductsQuantity = () => {
const searchPageContext = useSearchPage();
const handleChange: React.ChangeEventHandler = (event) => {
const quantItems = Number(event.currentTarget.value);
if (isNaN(quantItems)) return;
const page = searchPageContext.page - 1;
const initial = page * quantItems;
const final = initial + quantItems - 1;
searchPageContext.searchQuery.refetch({
from: initial,
to: final,
page: page
});
}
return (
<select name= "product-quantity" onChange = { handleChange } >
4 < /option>
< option value = "8" > 8 < /option>
< option value = "12" > 12 < /option>
< option value = "16" > 16 < /option>
< option value = "20" > 20 < /option>
< /select>
);
}

export default FilterProductsQuantity;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant