Closed sidneylopes closed 4 years ago
Add categories you want to the search criteria of request.
where is that?
I managed to filter the products,
where did you filter products?
in the getSearchCreteriaForCategoryAndChild function
src/magento/lib/admin/index.js
getSearchCreteriaForCategoryAndChild: (category, pageSize = 10, offset = 1, sortOrder, filter)
it takes category
as a parameter
could you give me an example of how you would filter categories?
@sidneylopes
check src/actions/RestActions.js
export const getProductsForCategoryOrChild = (category, offset, sortOrder, filter) => async (dispatch) => {
if (offset) {
dispatch({ type: MAGENTO_LOAD_MORE_CATEGORY_PRODUCTS, payload: true });
}
if (!offset && (typeof sortOrder === 'number' || typeof filter !== 'undefined')) {
dispatch({ type: MAGENTO_RESET_CATEGORY_PRODUCTS });
}
try {
const payload = await magento.admin
.getSearchCreteriaForCategoryAndChild(category, 10, offset, sortOrder, filter);
dispatch({ type: MAGENTO_GET_CATEGORY_PRODUCTS, payload });
dispatch({ type: MAGENTO_LOAD_MORE_CATEGORY_PRODUCTS, payload: false });
updateConfigurableProductsPrices(payload.items, dispatch);
} catch (e) {
logError(e);
}
};
but isn't that function for filtering products? I need to filter categories. let's suppose that I only want a category that has an Id of 20. How would I filter that?
Ok, this issue about product filter, isn't it? so I supposed you are asking about filter products by categories.
Also, you are asking a lot of questions I don't have in my mind I need to find an answer for you. So probably you can do it yourself. What did you try and where you stuck with it?
I already managed to filter the products, and the categories work, but I have 2 sites and in one of them, some categories aren't supposed to show up. I tried to filter them using a searchCriteria for their Ids, but it didn't work. I have no idea on how to do this.
Please share what you tried.
I managed to filter the products, and to show only the ones from the right store. How would I show only the right categories?