Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello KK,
Hope you are doing good? I need help or pointers with something I want to achieve. I want to filter out products that have specific sizes in the pp_options region (Size[ M | L | XL ]*) using the custom_field attribute of the pages tag. I have a dropdown filter field on the front-end which i want to use to filter products using query strings (eg. domain.com/products?size=xl). Thank you
Hi @adimpressions,

I'm not @KK, but if your only product option is 'Size', you could use custom_field="pp_options='XL'" in the <cms:pages> tag.

- - - - - - -

/products.php?size=XL
Code: Select all
<cms:set gpc_size="<cms:gpc 'size' method='get' />" />

<cms:pages masterpage='products.php' custom_field="pp_options='<cms:show gpc_size />'">
  // Lists all products containing 'XL' in pp_options field
</cms:pages>

Caveat:
This approach will search the entire pp_options field for option-values including 'M'. So if any of your products contain multiple options, say, Size[M | L | XL] and Type[Cotton | Merino Wool=+100], then the querystring value of 'M' would return both 'Medium' and 'Merino Wool' products (even if the Merino Wool products only had sizes L and XL).

There's probably a way to filter more granularly to avoid those collisions by running some <cms:if> statements within the <cms:pp_product_options> and <cms:pp_option_values> tags within the product's <cms:pages> tag and dumping relevant results in a Couch array. Seems like that could get a little complex, but could make for an elegant solution if you have many product options.
Thank you very much for the help me with my problem. However I already tried what you just mentioned but didn't work they way I expected it to and that was why I brought it here for help. Just like you mentioned in your caveat, when a user filters by Size = S ( S for small), the pages tag returns all the products because there is an S in the Size[M | L | XL] variants field of all the products.
3 posts Page 1 of 1
cron