2. Models¶
2.1. Variant¶
Every variant is represented by Variant instance and has following properties:
| Method | Description | Type |
|---|---|---|
| master | Defines whether variant is master | boolean |
| presentation | Name displayed to user. | string |
| object | Related product | VariableInterface |
| options | Option values | OptionValueInterface[] |
| createdAt | Date of creation | DateTime |
| updatedAt | Date of the last update | DateTime |
This model implements VariantInterface, you need to implement these extra methods:
| Method | Description | Returned value |
|---|---|---|
| addOption(OptionValueInterface $option) | Adds option value | Void |
| removeOption(OptionValueInterface $option) | Removes option from variant | Void |
| hasOption(OptionValueInterface $option) | Checks whether variant has given option | Boolean |
| setDefaults(VariantInterface $masterVariant) | This method is used toinherit values from a master variant | Void |
2.2. Option¶
Every variant option is represented by Option instance and has following properties:
| Method | Description | Type |
|---|---|---|
| name | Internal name | string |
| presentation | Name displayed to user | string |
| values | Option values | OptionValueInterface[] |
| createdAt | Date of creation | DateTime |
| updatedAt | Date of the last update | DateTime |
This model implements OptionInterface, you need to implement these extra methods:
| Method | Description | Returned value |
|---|---|---|
| addValue(OptionValueInterface $option) | Adds option value | Void |
| removeValue(OptionValueInterface $option) | Removes option value | Void |
| removeValue(OptionValueInterface $option) | Checks whether option has given value | Boolean |
2.3. OptionValue¶
Every variant option value is represented by OptionValue instance and has following properties:
| Method | Description | Type |
|---|---|---|
| value | Option internal value | string |
| option | Option | OptionInterface |
| createdAt | Date of creation | DateTime |
| updatedAt | Date of the last update | DateTime |
This model implements OptionInterface, you need to implement these extra methods:
| Method | Description | Returned value |
|---|---|---|
| getName() | Proxy method to access the name of real option object | string |
| getPresentation() | Proxy method to access the presentation of real option object | string |
2.4. VariableInterface¶
This interface should be implemented by models that support variants and options.
| Method | Description | Returned value |
|---|---|---|
| getMasterVariant() | Returns master variant | VariantInterface |
| setMasterVariant(VariantInterface $variant) | Sets master variant | Void |
| hasVariants() | Checks whether object has variant | Boolean |
| getVariants() | Returns all object variants | VariantInterface[] |
| setVariants(Collection $variants) | Sets all object variants | Void |
| addVariant(VariantInterface $variant) | Adds variant | Void |
| removeVariant(VariantInterface $variant) | Removes variant from object | Void |
| hasVariant(VariantInterface $variant) | Checks whether object has given variant | Boolean |
| hasOptions() | Checks whether object has given option | Boolean |
| getOptions() | Returns all object options | OptionInterface[] |
| setOptions(Collection $options) | Sets all object options | Void |
| addOption(OptionInterface $option) | Adds option | Void |
| removeOption(OptionInterface $option) | Removes option from product | Void |
| hasOption(OptionInterface $option) | Checks whether object has given option | Boolean |