Unfortunately, it is a problem. I can't rely on a unique combination of 
options (in some cases it will only be the dimensions that differ).

The ProductVariation manager does have a check that ensures option sets 
must be unique in order to save the variation (the try/except): 
    def create_from_options(self, options):
        """
        Create all unique variations from the selected options.
        """
        if options:
            options = SortedDict(options)
            # Build all combinations of options.
            variations = [[]]
            for values_list in list(options.values()):
                variations = [x + [y] for x in variations for y in 
values_list]
            for variation in variations:
                # Lookup unspecified options as null to ensure a
                # unique filter.
                variation = dict(list(zip(list(options.keys()), variation)))
                lookup = dict(variation)
                lookup.update(self._empty_options_lookup(exclude=variation))
                try:
                    self.get(**lookup)
                except self.model.DoesNotExist:
                    self.create(**variation)

It's soooo tempting to hack away at some of these files but I'll persevere 
and find a way of doing it while leaving the cartridge files intact :)

On Monday, May 25, 2015 at 7:32:45 PM UTC+10, Mathias Ettinger wrote:
>
> If you used EXTRA_MODEL_FIELDS to inject fields into ProductVariation, 
> then ProductVariation.option_fields won't consider them for the “identity 
> check” unless they are of type cartridge.shop.fields.OptionField (which I 
> doubt, I would bet on regular IntegerField).
>
> So it might not be a problem for you.
>
>
> Le lundi 25 mai 2015 10:56:06 UTC+2, Tomlin a écrit :
>>
>> Good thing you pointed that out. I just read this - "You'll also see in 
>> ProductVariation.option_fields its used as an identity check".
>>
>> Seems I still need every variation to have a unique set of options. Doh!
>>
>> On Monday, May 25, 2015 at 6:35:37 PM UTC+10, Mathias Ettinger wrote:
>>>
>>> There is also the begining of a discussion on dynamic variation fields 
>>> here: https://github.com/stephenmcd/cartridge/issues/232
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to