thelia/attribute-type-module

Installs: 1 192

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 5

Open Issues: 1

Type:thelia-module

1.3.4 2023-04-17 20:04 UTC

This package is auto-updated.

Last update: 2024-10-17 23:32:43 UTC


README

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

  • This module allows you to add to your attributes the attributes types.
  • Example : Color, Image link to the textures ...
  • An attribute can have several types.
  • An attribute 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 AttributeType.
  • Activate it in your thelia administration panel

Composer

Add it in your main thelia composer.json file

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

Usage

  • Once activated, click on the configure button for add or edit the attributes types.
  • For associate an attribute to an attribute type, edit an attribute.

Hooks

backoffice :

  • attribute-type.form-top (in form : create, update, attribute type) (params : attribute_type_id)
  • attribute-type.form-bottom (in form : create, update, attribute type) (params : attribute_type_id)
  • attribute-type.configuration-top
  • attribute-type.configuration-bottom
  • attribute-type.configuration-action (by attribute type) (params : attribute_type_id)
  • attribute-type.configuration-js

Loop

attribute_type

Input arguments

Output arguments

attribute_extend_attribute_type

Extends the Thelia loop : Attribute

Other input arguments

Other output arguments

  • The attributes 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="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

Extends the Thelia loop : Attribute availability

Other output arguments

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

Example

    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}

Model

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