thelia/feature-type-module

Installs: 1 993

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 5

Open Issues: 1

Type:thelia-module

2.0.0 2021-04-28 13:28 UTC

This package is auto-updated.

Last update: 2024-11-29 05:03:17 UTC


README

Authors: Thelia info@thelia.net, Gilles Bourgeat gilles.bourgeat@gmail.com

  • 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.

Scrutinizer Code Quality License Latest Stable Version

Compatibility

Thelia >= 2.1

Installation

Manually

  • Copy the module into <thelia_root>/local/modules/ directory and be sure that the name of the module is FeatureType.
  • Activate it in your thelia administration panel

Composer

Add it in your main thelia composer.json file

composer require thelia/feature-type-module:~1.3.0

Usage

  • 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.

Hooks

backoffice :

  • 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

Loop

feature_type

Input arguments

Output arguments

feature_extend_feature_type

Extends the Thelia loop : Feature

Other input arguments

Other output arguments

  • 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.

Example

    {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}

feature_availability_extend_feature_type

Extends the Thelia loop : Feature availability

Other input arguments

Other output arguments

  • The features types associated.
  • The variable name is equal to the name of the slug,
  • The variable contains the value.

Example

    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}

feature_value_extend_feature_type

Extends the Thelia loop : Feature value

Other output arguments

  • The features types associated.
  • The variable name is equal to the name of the slug,
  • The variable contains the value.

Example

    title : color
    {loop name="feature_value_extend_feature_type" type="feature_value_extend_feature_type" feature="1" product="1"}
        {$TITLE} : {$COLOR} <br/>
    {/loop}

Model

FeatureType::getValue

    /**
     * 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')

FeatureType::getValues

    /**
     * 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')

FeatureType::getFirstValues

    /**
     * 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')

FeatureType::getFeatureAv

    /**
     * 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')

FeatureType::getFeatureAvs

    /**
     * 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')