[ic] RE: Options Problem

Jon Jensen jon at endpoint.com
Sat Sep 4 01:42:29 EDT 2004

On Thu, 2 Sep 2004 joe at cyberseals.net wrote:

> But I figured it out, so I'll put this out there for anybody else who
> wants to use the standard options support without having to key the
> options on the product SKU...


Thanks for posting your detailed write-up to the list. It's great to see
experience shared, and makes the mailing list archives quite useful. :)

> So the only issue remaining now is how to associate products in the
> external database with this new options type. In the foundation catalog, a
> product must have a value in the "option_type" field in order to use the
> newer-style options. The value in this field references the Options module
> to use for this product (so here we clearly want the value to be
> "TypeSimple" for all of the products in the external database).
> Unfortunately, I haven't figured out an elegant solution to this problem,
> so what I ended up doing is *temporarily* (hehe) breaking the rules and
> adding an "option_type" field to the external products database table.
> Since I always want it to have the same value for all products in that
> database, I just set the default value for the field to "TypeSimple" and
> voila!

I ran into the same thing for a client about a year ago, and decided to
add a feature to the Options module to handle this. In my tentative
solutions, when you prefix the option_type field name with a * it means
that instead you're giving a module name, not a field name, like this:

OptionsEnable option_type *TypeSimple

That's implemented with this simple patch:

--- ic/ic53/lib/Vend/Options.pm	Wed Jun 18 11:34:44 2003
+++ Options.pm	Fri Sep  3 23:38:23 2004
@@ -74,7 +74,14 @@
 	if($Vend::Cfg->{OptionsEnable}) {
 		my ($tab, $field) = split /:+/, $Vend::Cfg->{OptionsEnable};
-		if(! $field) {
+		if($tab =~ /\*/) {
+			my $att;
+			($att, $tab) = split /\s*\*\s*/, $tab;
+			$attrib ||= $att;
+			$item->{$attrib} ||= $tab;
+			undef $tab;
+		}
+		elsif(! $field) {
 			$field = $tab;
 			undef $tab;

I hadn't decided whether I liked this solution or not, in particular the
somewhat non-obvious * notation, and was waiting to think of some better
ideas before committing it to mainline Interchange. Does something like
that sound like it would work for you? You wouldn't need an "option_type"
field then, which would always have the same value anyway.


Jon Jensen
End Point Corporation
Software development with Interchange, Perl, PostgreSQL, Apache, Linux, ...

More information about the interchange-users mailing list