In the query to filter on the category you can just add to the where clause like this:
WHERE optiongroups.OptionGroupName = 'color' AND productoptions.ProductID = paramItem AND options.CategoryID = <the category id to compare to>
If you are working in the advanced view then you will need to add a query parameter and set it to the variable that this value comes from. If the pages are setup for the large and small bags then you can just enter the category id number for the size of bag you are working with.