Hi,
I have a case: I need to hide some products on the collection page, collection/all and in the search results page based on some product tag/metafield, unfortunately when I add conditions and do not render these products there is a problem with pagination. For example:
I have 17 products, 16 per page. From the first page I skipped 1 product - it created an empty space, I still have 2 pages of products and on the second page I have 1 product - which should jump to the 1st page.
Has anyone found a solution to this issue with pagination?
You can’t do this, currently. You cant exclude products from the pagination object, so that will always be buggy.
Either remove product/page counts and live with mismatched products pr page (instead of eimply skipping the iteration you could swap it with a promo block) or strategially use tailored Smart Collection rules to avoid the products in your collections.
Search results can be fixed by adding a Product metafield definition of {"type": "Integer", "key": "seo", "hidden"} and set it to 1 for the Products that should not be visible in search (internally and externally). And yes, it has to be a Int 0 or 1, not a Boolean. Read more here: Optimize storefront SEO