thelia/feature-type-module

安装次数: 1,948

依赖: 1

建议者: 0

安全: 0

星标: 0

关注者: 8

分支: 5

开放问题: 1

类型:thelia-module

2.0.0 2021-04-28 13:28 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:21 UTC


README

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

  • 此模块允许您将特性类型添加到您的特性中。
  • 示例:颜色、图片链接到纹理...
  • 一个特性可以有多个类型。
  • 特性类型可以有值或没有值。
  • 值可以按语言唯一。

Scrutinizer Code Quality License Latest Stable Version

兼容性

Thelia >= 2.1

安装

手动

  • 将模块复制到 <thelia_root>/local/modules/ 目录,并确保模块名称为 FeatureType
  • 在Thelia管理面板中激活它

Composer

将其添加到您的thelia主composer.json文件中

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

使用方法

  • 激活后,点击配置按钮添加或编辑特性类型。
  • 要关联一个特性到一个特性类型,编辑一个特性。

钩子

backoffice

  • feature-type.form-top(在表单中:创建、更新、特性类型)(参数:feature_type_id)
  • feature-type.form-bottom(在表单中:创建、更新、特性类型)(参数:feature_type_id)
  • feature-type.configuration-top
  • feature-type.configuration-bottom
  • feature-type.list-action(按特性类型)(参数:feature_type_id)
  • feature-type.configuration-js

循环

feature_type

输入参数

输出参数

feature_extend_feature_type

扩展Thelia循环: 特性

其他输入参数

其他输出参数

  • 关联的特性类型。
  • 变量名等于slug的名称,
  • 值是布尔值,关联为true,未关联为false。

示例

    {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

扩展Thelia循环: 特性可用性

其他输入参数

其他输出参数

  • 关联的特性类型。
  • 变量名等于slug的名称,
  • 变量包含值。

示例

    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

扩展Thelia循环: 特性值

其他输出参数

  • 关联的特性类型。
  • 变量名等于slug的名称,
  • 变量包含值。

示例

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

模型

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