How to create a dynamic attribute

What is dynamic attribute?

Dynamic attribute - it's attribute, that can return values depends on conditions or value of another attributes.

To create a new dynamic attribute, follow these steps:

  1. Go to Catalog > Manage Feeds > Manage Dynamic Attributes. Press button Add Attribute.
    dynamic_main.png
  2. Fill in the following fields:

    • Attribute Name - name of the dynamic attribute
    • Attribute Code - code of the dynamic attribute. You will see this code when you select this dynamic attribute in the templates.
  3. At Conditions tab, set conditions.

    • Press Add New Value
    • Select attribute at left corner
    • Select condition
    • Select or input condition value
    • Select Output Type:
      • Attribute Value - allows to return attribute values for the specified conditions.
      • Pattern - patterns allow to use for output values attributes with php functions.
    • Select attribute or input pattern at Output Value - when condition is true, dynamic attribute will return this value.
  4. Set Default value - sets output value for the attribute, which is not described in the conditions of the dynamic attribute.
  5. Press button Save.

These settings you can read this way:
If Condition is TRUE, then this attribute will have next Output Value. If none of the conditions are TRUE, the attribute will have Default Value.
dynamic_description.png


You can select created Dynamic attributes from the drop down list of the store attributes.
~! In the feed templates, dynamic attributes must contain the phrase "custom:" in the beginning: {custom:attribute_code}

  • If output type "Attribute", select attribute from the group Dynamic Attributes. Phrase "custom:" adds automatically.
  • If output type "Pattern", don't forget to add manually phrase "custom:" in the beginning of the dynamic attribute.

dynamic_description2

Dynamic Attribute Examples

  • How to set output Google Shopping acceptable values for gender: male, female, unisex

    Google accept only one of three values for gender: male, female, unisex. Your merchant store may have another values for gender.
    For example, gender values: Mens and Womens. To replace these values, we create two conditions and set appropriate output values for genders. If product don't have gender "Mens" or "Womens" attribute values, it will have Default Value - unisex.

    dynamic_gender.png

  • An example of why position of the conditions must be set correctly.

    In this dynamic attribute for the Silver color we need to set ouput value Matte Silver. For all other colors, we need to set ouput value Multi.
    If you set conditions with the same order posiotions as at this image, then this dynamic attribute will not work correctly!
    First Condition: Color is not empty will replace all existent Colors to value Multi(including color Silver). So when second Condition search for Silver color, it will not find any values.
    To make it work correctly, you need to change position of the conditions. dynamic_color.png

Dynamic attribute examples with Subconditions

~! If you use subconditions, all selected conditions will be applied at the same moment

  • For the AMD brand products, which have price between 200 and 500, we need to set ouput price with 20% discount.

    To cover all requirements, we need to use Subconditions.
    Select AMD manufacturer and add two subconditions: Price equals or greater than 200 and Price equals or lower than 500.
    To get 20% price discount at the Output value, we used one of the php patterns{(return ($price*0.8);)}. For more examples and information about patterns, see List of Patterns

    You can add in this dynamic attribute discount for another price limits. To do this, you need to add a new Condition with subconditions. (See next example)

    dynamic_price.png

  • How to set proper output values for product stock statuses with quantity subconditions.

    In the dynamic attribute for the attribute Is In Stock you can use next possible values:

    • 0 - Out of Stock
    • 1 - In Stock
      figure
Advanced Product Feeds