Eigenschaften aus Filterauswahl Gambio

How can you display values from an item's filter selection in the product list / category overview? For example, if a product is available in certain sizes (e.g. XS, S, M, and L), you can already inform a customer looking for size XXL in the product overview (without requiring them to activate the corresponding filter first), saving the user unnecessary clicks on products that are not available in the desired size. The same applies to available colors: If you want to supplement the filtering options (e.g. yellow, red, green, blue, white, black, gray) and display more specific colors directly in the Gambio product overview (e.g. sky blue, azure blue, turquoise, or cobalt blue), you can use the filter assignments.

 

 First, we create a class overload for the "product" class. In our example, we make this declaration in the file

 

\user_classes\overloads\product\ECONCESS_product.inc.php

 

and extend the buildDataArray(&$array, $image = 'thumbnail') function using the following syntax:

 

class ECONCESS_product extends ECONCESS_product_parent{

function buildDataArray(&$array, $image = 'thumbnail')
{
   $t_data_array = parent::buildDataArray($array, $image);
   $product_id = $array['products_id'];

   $t_feature_set_query = xtc_db_query("SELECT feature_value_description.feature_value_text
      FROM feature_set_to_products
      LEFT JOIN feature_set_values
      ON feature_set_to_products.feature_set_id=feature_set_values.feature_set_id
      LEFT JOIN feature_value
      ON feature_set_values.feature_value_id=feature_value.feature_value_id
      LEFT JOIN feature_value_description
      ON feature_value.feature_value_id=feature_value_description.feature_value_id
      WHERE feature_set_to_products.products_id = '" . $product_id . "'
      AND feature_value.feature_id = 9
      ");

   if(xtc_db_num_rows($t_feature_set_query) > 0)
   {
      while($t_feature_set = xtc_db_fetch_array($t_feature_set_query))
      {
         $t_feature_set_values[] = $t_feature_set['feature_value_text'];
      }
      $t_data_array['PRODUCTS_COLORSWATCH'] = implode(" - ",$t_feature_set_values);
   }
return $t_data_array;
}

}

 

So, what exactly have we done here?

 

First, we populated the data array as described in the parent class or its existing overloads. In addition, we want to provide the template with the entry "PRODUCTS_COLORSWATCH", which we can then use in the product overview to display the available color variants – in this simplified example, as text.

 

To do this, we first need to use the "feature_sets_to_products" table, which shows us which Feature Set ID is assigned to which product. We then join this with the "feature_set_values" table to determine which Value IDs belong to the respective Feature Set. To extract the desired filter, we use the "feature_value" table and only retrieve the values with Feature ID 9 (in our example, Feature ID 9 corresponds to the "Color" filter).

 

Finally, we add the "feature_value_description" table, which provides the corresponding option descriptions (e.g. "Black" and "White", joined here using implode() to produce "Black - White").

 

We can then use the resulting entry in the file

 

\templates\TEMPLATENAME\objects\product_boxes_list.html

 

or in the respective output file and display it at the desired location using the Smarty variable

 

{$module_data.PRODUCTS_COLORSWATCH}

 

That's it.