By cghobbs on
I am needing to filter by product type in views, but as far as I can see this option isnt available. I tried creating a module to do this but so far no luck. The module was named grid_pricing.module (I'm not sure if the name of the module matters).
function grid_pricing_views_tables() {
$tables['users'] = array(
'name' => 'ec_product',
'filters' => array(
'ptype' => array(
'name' => t('Product: Type'),
'operator' => 'views_handler_operator_or',
'list' => 'grid_pricing_handler_filter_type',
'value-type' => 'array',
'help' => t('This allows you to filter by product type.'),
),
)
);
return $tables;
}
function grid_pricing_handler_filter_type($op, $filterinfo) {
$ptypes = array();
$result = db_query("SELECT DISTINCT p.ptype FROM {ec_product} p ");
while ($obj = db_fetch_object($result)) {
$ptypes[$obj->ptype] = $obj->ptype;
}
return $ptypes;
}
Comments
Are your Products cck
Are your Products cck content types? If so, you can easily filter by 'Node: Type' in views.