$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToSelect('name','your-attribute');
$collection->addAttributeToFilter('your-attribute', array('eq' => 'attr-value'));
or
$category = Mage::getModel('catalog/category')->load($categoryId);
$collection = Mage::getModel('catalog/product')->getCollection()
->addCategoryFilter($category);
How can I achieve in Magento2.0
I want to filter the product collection by category id, custom category attribute(store id, customer group id).
I have create two custom attribute for category in Magento admin for Store and customer segmentation, I provide the options as Multiselect in the following way,
for store selection(in the dropdown, all store created come dynamically ).
for segmentation selection(in the dropdown, all customer group created come dynamically )
Now i want to filter product collection on the basis of attribute filter(store id, customer group id)

