[ic] Single widget matrix options

Jamie Neil interchange-users@icdevgroup.org
Mon Apr 14 10:25:01 2003


> -----Original Message-----
> From: interchange-users-admin@icdevgroup.org
> [mailto:interchange-users-admin@icdevgroup.org]On Behalf Of Mike Heins
> Sent: 14 April 2003 14:54
> To: interchange-users@icdevgroup.org
> Subject: Re: [ic] Single widget matrix options
>
>
> Quoting Jamie Neil (jamie@versado.net):
> > I am trying to use matrix options with a single widget selector
> rather than
> > separate wigdets as my products do not come in a full set of
> combinations
> > e.g. Big and Red, Small and Blue, Big and Blue but not Small
> and Red. But
> > when I try to use the [item-options] tag, I get no output at all.
> >
> > Change to separate widgets and it works fine, but that allows
> someone to try
> > to buy invalid option combinations (e.g. Small Red things).
> >
> > Am I misunderstanding the tag/options or is this a bug?
> >
> > I am using the 4.9.7-200304010658 snapshot.
>
> It works for me. But the question is, are you using "Old48" options
> or the new Matrix ones? I suspect you are on Old48, and you can tell
> by the "Change option" page. If you see a choice of Simple, Matrix
> separate widget, Matrix single widget, and Modular, then you are
> on Old48-style options.

I appear to be using the newer options (I see a choice of None, Simple,
Matrix or Old Interchange 4.8 Options).

>
> I guess I don't know quite what I did with that code. I think it
> should resolve it OK if you set the o_matrix field in the options
> master record to 2, but looking at the code try this:
>
> 	[item-options display_type=single]
>

I've had a dig around in Matrix.pm and switched the debugging options on,
and it seems that when the single widget option is set, the database SELECT
fails because of the default sort fields that are built into the code:

/tmp/icdebug
------------
Vend::Options::Matrix:debug: tag_options matrix query: SELECT
code,description,price FROM variants where sku = '00013' AND code like
'00013-%' ORDER BY o_sort,o_group
Vend::Options::Matrix:debug: tag_options matrix ary: []

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";

...


The separate widget is ok because it references the "Options" table which
has the o_sort and o_group fields. However the single widget fails because
it references the "Variants" table which doesn't have these fields.

As a workaround I provided a null sort as an argument to the options tag,
but this obviously clobbers the option sorting on products that use separate
widgets:

	[item-options sort=""]

Do you have any other suggestions?

Jamie

> --
> Mike Heins
> Perusion -- Expert Interchange Consulting    http://www.perusion.com/
> phone +1.513.523.7621      <mike@perusion.com>
>
> "Even if you're on the right track, you'll get run over if you just
> sit there." -- Will Rogers
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>