/**
  * Multiple-fields (e.g. select or checkbox) with numberic keys are stored as CSV to improve filters.
  */
 private function convertSerializedValues()
 {
     $t = Attribute::getTable();
     $fields = array();
     $attributes = Attribute::findBy(array("{$t}.multiple='1' AND {$t}.optionsSource='foreignKey'"), null);
     if (null !== $attributes) {
         /** @var Attribute $attribute */
         foreach ($attributes as $attribute) {
             if ($attribute instanceof IsotopeAttributeWithOptions) {
                 $fields[] = $attribute->field_name;
             }
         }
     }
     if (!empty($fields)) {
         /** @var \Database\Result|object $products */
         $products = $this->db->execute("\n                SELECT id, " . implode(', ', $fields) . "\n                FROM tl_iso_product\n                WHERE " . implode(" IS NOT NULL OR ", $fields) . " IS NOT NULL\n            ");
         while ($products->next()) {
             $set = array();
             foreach ($fields as $field) {
                 $value = deserialize($products->{$field});
                 if (!empty($value) && is_array($value)) {
                     $set[$field] = implode(',', $value);
                 }
             }
             if (!empty($set)) {
                 $this->db->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($set)->execute($products->id);
             }
         }
     }
 }