[ic] Single widget matrix options

Mike Heins interchange-users@icdevgroup.org
Mon Apr 14 12:36:01 2003


Quoting Jamie Neil (jamie@versado.net):
> > Here's the relevent code sections:
> >
> > Matrix.pm
> > ---------
> > ...
> >
> > %Default = (
> >                                 no_pricing => 1,
> >                                 item_add_routine =>
> > 'Vend::Options::Matrix::testit',
> >                                 table => 'options',
> >                                 variant_table => 'variants',
> >                                 sort => 'o_sort,o_group',
> >                         );
> >
> > ...
> >
> >         my ($item, $opt, $loc) = @_;
> >
> > ...
> >
> >         my $rsort = find_sort($opt, $db, $loc);
> >
> > ...
> >
> >                 my $q = "SELECT " . join(",", @rf);
> >                 $q .= " FROM $vname where $lcol = $lval AND $ccol
> > like $cval
> > $rsort";
> 
> On a slightly different note, why SELECT on SKU AND code? Surely if SKU
> matches then that is enough - checking for the SKU as a prefix on the code
> is unnecessary (or am I missing something?).

This is baggage from the untidy record format of the past, where the
option groups and variants were stored in the same table.

> Also, if the code prefix were
> omitted from the search, then it means the SKUs for the options don't have
> to be tied to the master item (e.g. SKU=123, option SKUs=1001,1002 and 1003
> rather than 123-1,123-2,123-3).

They do if you want to have switchable single/separate display, for it
relies on that for building the SKU for the separate widget options.

But the beauty of this new thing is that you can do:

  % cd lib/Vend
  % cp Options/Matrix.pm Options/Jamie.pm
  % perl -pi -e 's/Matrix/Jamie/g' Options/Jamie.pm
  % echo "update products set option_type = 'Jamie' where option_type = 'Matrix'" | mysql your_dsn
  % echo 'Options Jamie sort ""' >> /var/lib/interchange/yourcat/catalog.cfg
  % bin/restart

and have a completely new Options type you can edit and do to your
hearts content. (That script is not presented as something to do, only
to show the idea.)

Of course I would appreciate significant patches and improvements to the
current ones....

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

Prove you aren't stupid.  Say NO to Passport.