[ 
https://issues.apache.org/jira/browse/OFBIZ-1393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543294
 ] 

Chris Lombardi commented on OFBIZ-1393:
---------------------------------------

(Adding to jira, sorry about the double post.  An edit is included below.)

Agreed that this should not go to release4.0, I just wanted to be clear that I 
hadn't tested it on release4.0.

1.  The way I did it allows for multiple products using the same set of 
ProductConfigOptions but allows for different defaults.  For example, using the 
example configurable product pc001, it uses the same ProductConfigOption twice 
for the first and second HDD.  Had I done it the suggested way, the default 
would have to be the same for both questions, or I would have to recreate the 
same ProductConfigOptions, but with a different default in the 
ProductConfigOptions table.

productId       configItemId description                        configTypeId 
defaultConfigItemId        
PC001   IT0001          1st Hard Disk drive             QUESTION        OP003
PC001   IT0001  2nd Hard Disk drive             QUESTION        

This shows that the 1st HDD defaults to OP003, but has no default for the 2nd 
HDD.

Edit:  Putting the default in the ProductConfigItem (PCI) also causes extra PCI 
to be created for products that share the same PCI.  I just thought that the 
default configuration of a product is most closely associated to the product 
itself, instead of the question or the potential answers.

2.  Oops, good catch.  I'll fix that.

Thanks for the code review.

Chris


> Need a better way to specify the default item configuration
> -----------------------------------------------------------
>
>                 Key: OFBIZ-1393
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1393
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: product
>    Affects Versions: SVN trunk, Release Branch 4.0
>            Reporter: Chris Lombardi
>            Priority: Minor
>         Attachments: ofbiz-1393.patch
>
>
> Currently, setDefaultConfig in ProductConfigWrapper assumes the default is 
> the first ProductConfigOption.  I would like to be able to set up different 
> products that shared a set of ProductConfigOptions yet allow for a different 
> default ProductConfigOption.
> I don't yet have an opinion on how I can best implement this and my Data 
> Model Resource Book is in the mail.  Does anyone have any thoughts or 
> preferences?
> Here's how it's currently implemented:
>     public void setDefaultConfig() {
>         resetConfig();
>         for (int i = 0; i < questions.size(); i++) {
>             ConfigItem ci = (ConfigItem)questions.get(i);
>             if (ci.isMandatory()) {
>                 if (ci.getOptions().size() > 0) {
>                     ConfigOption co = (ConfigOption)ci.getOptions().get(0);  
> // default is first option
>                     co.setSelected(true);
>                 }
>             }
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to