thelia/attribute-type-module

安装数: 1,186

依赖关系: 1

建议者: 0

安全: 0

星标: 0

关注者: 8

分支: 5

公开问题: 1

类型:thelia-module

1.3.4 2023-04-17 20:04 UTC

This package is auto-updated.

Last update: 2024-09-17 23:20:17 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/ 目录,并确保模块的名称为 AttributeType
  • 在 Thelia 管理面板中激活它

Composer

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

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

使用方法

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

钩子

backoffice

  • attribute-type.form-top (在表单:创建、更新、属性类型) (参数:attribute_type_id)
  • attribute-type.form-bottom (在表单:创建、更新、属性类型) (参数:attribute_type_id)
  • attribute-type.configuration-top
  • attribute-type.configuration-bottom
  • attribute-type.configuration-action (按属性类型) (参数:attribute_type_id)
  • attribute-type.configuration-js

循环

attribute_type

输入参数

输出参数

attribute_extend_attribute_type

扩展 Thelia 循环:[属性](http://doc.thelia.net/en/documentation/loop/attribute.html) (参数:attribute_type_id)

其他输入参数

其他输出参数

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

示例

    {loop name="attribute_extend_attribute_type" type="attribute_extend_attribute_type" attribute_type_id="1,2,3"}
        {$TITLE} <br/>

        {if $COLOR}
            The attribute has type color
        {/if}

        {if $MY_ATTRIBUTE_TYPE}
            The attribute has type "My attribute type"
        {/if}
    {/loop}

attribute_availability_extend_attribute_type

扩展 Thelia 循环:[属性可用性](http://doc.thelia.net/en/documentation/loop/attribute_availability.html) (参数:attribute_type_id)

其他输出参数

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

示例

    title : color : my attribute type
    {loop name="attribute_availability_extend_attribute_type" type="attribute_availability_extend_attribute_type" attribute="1"}
        {$TITLE} : {$COLOR} : {$MY_ATTRIBUTE_TYPE} <br/>
    {/loop}

    title : color : my attribute type
    {loop name="attribute_availability_extend_attribute_type" type="attribute_availability_extend_attribute_type" attribute_type_slug="color"}
        {$TITLE} : {$COLOR} : {$MY_ATTRIBUTE_TYPE} <br/>
    {/loop}

模型

AttributeType::getValue

    /**
     * Returns a value based on the slug, attribute_av_id and locale
     *
     * <code>
     * $value  = AttributeType::getValue('color', 2);
     * </code>
     *
     * @param string $slug
     * @param int $attributeAvId
     * @param string $locale
     * @return string
     * @throws \Propel\Runtime\Exception\PropelException
     */
    public static function getValue($slug, $attributeAvId, $locale = 'en_US')

AttributeType::getValues

    /**
     * Returns a set of values
     * If the value does not exist, it is replaced by null
     *
     * <code>
     * $values = AttributeType::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[] $attributeAvIds
     * @param string $locale
     * @return string
     * @throws \Propel\Runtime\Exception\PropelException
     */
    public static function getValues(array $slugs, array $attributeAvIds, $locale = 'en_US')

AttributeType::getFirstValues

    /**
     * Returns a set of first values
     * If the value does not exist, it is replaced by null
     *
     * <code>
     * $values = AttributeType::getFirstValues(['color','texture', 'other'], [4,7]);
     * </code>
     *
     * <sample>
     *  array(
     *  'color' => '#00000',
     *  'texture' => 'lines.jpg',
     *  'other' => null
     * )
     * </sample>
     *
     * @param string[] $slugs
     * @param int[] $attributeAvIds
     * @param string $locale
     * @return array
     */
    public static function getFirstValues(array $slugs, array $attributeAvIds, $locale = 'en_US')

AttributeType::getAttributeAv

    /**
     * Find AttributeAv by slugs, attributeIds, values, locales
     *
     * <code>
     * $attributeAv = AttributeType::getAttributeAv('color', '1', '#00000');
     * </code>
     *
     * @param null|string|array $slugs
     * @param null|string|array $attributeIds
     * @param null|string|array $values meta values
     * @param null|string|array $locale
     *
     * @return \Thelia\Model\AttributeAv
     */
    public static function getAttributeAv($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')

AttributeType::getAttributeAvs

    /**
     * Find AttributeAvs by slug, attributeId, value, locale
     *
     * <code>
     * $attributeAvs = AttributeType::getAttributeAvs('color', '1', '#00000');
     * </code>
     *
     * @param null|string|array $slugs
     * @param null|string|array $attributeIds
     * @param null|string|array $values meta values
     * @param null|string|array $locale
     *
     * @return \Thelia\Model\AttributeAv
     */
    public static function getAttributeAvs($slugs = null, $attributeIds = null, $values = null, $locale = 'en_US')