Authors: Thelia [email protected], Gilles Bourgeat [email protected]
- This module allows you to add to your features the features types.
- Example : Color, Image link to the textures ...
- An feature can have several types.
- An feature type can have values or not.
- Values can be unique by language.
Thelia >= 2.1
- Copy the module into
<thelia_root>/local/modules/
directory and be sure that the name of the module isFeatureType
. - Activate it in your thelia administration panel
Add it in your main thelia composer.json file
composer require thelia/feature-type-module:~1.3.0
- Once activated, click on the configure button for add or edit the features types.
- For associate an feature to an feature type, edit an feature.
- feature-type.form-top (in form : create, update, feature type) (params : feature_type_id)
- feature-type.form-bottom (in form : create, update, feature type) (params : feature_type_id)
- feature-type.configuration-top
- feature-type.configuration-bottom
- feature-type.list-action (by feature type) (params : feature_type_id)
- feature-type.configuration-js
Argument | Description |
---|---|
id | A single or a list of ids. |
exclude_id | A single or a list of ids. |
slug | String |
feature_id | A single or a list of features ids. |
Variable | Description |
---|---|
ID | The feature type id |
SLUG | The feature type slug |
TITLE | The feature type title |
DESCRIPTION | The feature type description |
CSS_CLASS | The feature type css class |
PATTERN | The feature type pattern |
INPUT_TYPE | The feature type input type |
MIN | The feature type minimum value |
MAX | The feature type maximum value |
STEP | The feature type step value |
IMAGE_MAX_WIDTH | The max width for image (in px) |
IMAGE_MAX_HEIGHT | The max height for image (in px) |
IMAGE_RATIO | The image ratio required |
IS_MULTILINGUAL_FEATURE_AV_VALUE | Indicates whether the values are unique for each language |
HAS_FEATURE_AV_VALUE | Indicates whether the type feature has values for each feature av |
Extends the Thelia loop : Feature
Argument | Description |
---|---|
feature_type_id | A single or a list of features type ids. |
feature_type_slug | A single or a list of features type slugs. |
- The features types associated.
- The variable name is equal to the name of the slug,
- The value is boolean, true for associated, false for unassociated.
{loop name="feature_extend_feature_type" type="feature_extend_feature_type" feature_type_id="1,2,3"}
{$TITLE} <br/>
{if $COLOR}
The feature has type color
{/if}
{if $MY_FEATURE_TYPE}
The feature has type "My feature type"
{/if}
{/loop}
Extends the Thelia loop : Feature availability
Argument | Description |
---|---|
feature_type_id | A single or a list of features type ids. |
feature_type_slug | A single or a list of features type slugs. |
- The features types associated.
- The variable name is equal to the name of the slug,
- The variable contains the value.
title : color : my feature type
{loop name="feature_availability_extend_feature_type" type="feature_availability_extend_feature_type" feature="1"}
{$TITLE} : {$COLOR} : {$MY_FEATURE_TYPE} <br/>
{/loop}
title : color : my feature type
{loop name="feature_availability_extend_feature_type" type="feature_availability_extend_feature_type" feature_type_slug="color"}
{$TITLE} : {$COLOR} : {$MY_FEATURE_TYPE} <br/>
{/loop}
Extends the Thelia loop : Feature value
- The features types associated.
- The variable name is equal to the name of the slug,
- The variable contains the value.
title : color
{loop name="feature_value_extend_feature_type" type="feature_value_extend_feature_type" feature="1" product="1"}
{$TITLE} : {$COLOR} <br/>
{/loop}
/**
* Returns a value based on the slug, feature_av_id and locale
*
* <code>
* $value = FeatureType::getValue('color', 2);
* </code>
*
* @param string $slug
* @param int $featureId
* @param string $locale
* @return string
* @throws \Propel\Runtime\Exception\PropelException
*/
public static function getValue($slug, $featureId, $locale = 'en_US')
/**
* Returns a set of values
* If the value does not exist, it is replaced by null
*
* <code>
* $values = FeatureType::getValue(['color','texture'], [4,7]);
* </code>
*
* <sample>
* array(
* 'color' => [4 => '#00000', 7 => '#FFF000'],
* 'texture' => [4 => null, 7 => 'lines.jpg']
* )
* </sample>
*
* @param string[] $slugs
* @param int[] $featureIds
* @param string $locale
* @return string
* @throws \Propel\Runtime\Exception\PropelException
*/
public static function getValues(array $slugs, array $featureIds, $locale = 'en_US')
/**
* Returns a set of first values
* If the value does not exist, it is replaced by null
*
* <code>
* $values = FeatureType::getFirstValues(['color','texture', 'other'], [4,7]);
* </code>
*
* <sample>
* array(
* 'color' => '#00000',
* 'texture' => 'lines.jpg',
* 'other' => null
* )
* </sample>
*
* @param string[] $slugs
* @param int[] $featureIds
* @param string $locale
* @return array
*/
public static function getFirstValues(array $slugs, array $featureIds, $locale = 'en_US')
/**
* Find FeatureAv by slugs, featureIds, values, locales
*
* <code>
* $featureAv = FeatureType::getFeatureAv('color', '1', '#00000');
* </code>
*
* @param null|string|array $slugs
* @param null|string|array $featureIds
* @param null|string|array $values meta values
* @param null|string|array $locale
*
* @return \Thelia\Model\FeatureAv
*/
public static function getFeatureAv($slugs = null, $featureIds = null, $values = null, $locale = 'en_US')
/**
* Find FeatureAv by slugs, featureIds, values, locales
*
* <code>
* $featureAv = FeatureType::getFeatureAvs('color', '1', '#00000');
* </code>
*
* @param null|string|array $slugs
* @param null|string|array $featureIds
* @param null|string|array $values meta values
* @param null|string|array $locale
*
* @return \Thelia\Model\FeatureAv
*/
public static function getFeatureAvs($slugs = null, $featureIds = null, $values = null, $locale = 'en_US')