AmberDB
view release on metacpan or search on metacpan
docs/EN.AmberDB_User-Guide.md view on Meta::CPAN
{ blk => 4, id => "price", label => "Price Range" },
# Free-Text Attributes (Color, Size, etc.):
{ blk => 6, id => "color", label => "Color" },
],
}
```
### 16.3 Usage & Practical Examples
#### A. Building Category Sidebar Menus
Generate complete filter groups and matching product counts in a single method call:
```perl
# User selections from URL query string: Category 5, Brand 12 or 14 selected
my %selected_filters = ( 1 => "5", 2 => ["12", "14"] );
my $menu = $adb->facet_menu(
"catalog_attributes",
\%selected_filters,
$table_info->{facet_block},
lib/AmberDB/Index/Facet.pm view on Meta::CPAN
{
target_block => $blk,
filter => \%excl,
base_ids => $base_scope,
}
);
$all_counts{$blk} = $cnt_map || {};
}
}
# 3. Build Menu Groups, Whitelist & Batch Label Resolution (.unq / RDBM)
my @groups;
my %groups_by_blk;
my %active_counts;
for my $cfg (@$facet_defs) {
my $blk = ref($cfg) eq 'HASH' ? $cfg->{blk} : $cfg;
my $label = ref($cfg) eq 'HASH' ? ( $cfg->{label} // "Grup $blk" ) : "Grup $blk";
my $counts = $all_counts{$blk} // {};
next unless %$counts || ( ref($cfg) eq 'HASH' && $cfg->{required} );
t/amberdb_ecommerce_facet.t view on Meta::CPAN
[ 5, 2, 20, 100, 'Nutuk', 'Ciltli', 1, 250.00 ],
[ 6, 2, 20, 100, 'Geometri', 'Karton', 1, 75.00 ],
[ 7, 3, 30, 300, 'Dune', 'Ciltli', 1, 280.00 ],
[ 8, 3, 30, 300, 'Dune Mesihi', 'Karton', 1, 160.00 ],
[ 9, 3, 30, 300, 'Dune Ãocukları (Pasif)', 'Karton', 0, 140.00 ], # JUNK / Inactive
);
$adb->insert_list( 'catalog_product', @products );
# ---------------------------------------------------------------------------
subtest '1. Initial Unfiltered Facet Menu & Label Resolution' => sub {
plan tests => 8;
my $menu = $adb->facet_menu(
'catalog_product',
{}, # No filter selected
$adb->table_attr('catalog_product', 'facet_block'),
{ sort => 'count' }
);
ok( $menu, "Facet menu generated successfully" );
( run in 0.769 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )