/**
  * 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);
             }
         }
     }
 }
Example #2
0
 public function __construct(\Database\Result $objResult = null)
 {
     // This class should not be registered
     // Set type or ModelType would throw an exception
     $this->arrData['type'] = 'pricetiers';
     parent::__construct($objResult);
 }
 /**
  * @param $arrData
  * @param $id
  * @return bool
  */
 public function saveAttributeOptions($arrData, $id)
 {
     $arrAttributeOptions = array();
     $time = time();
     $ptable = \Isotope\Model\Attribute::getTable();
     foreach ($arrData as $group => $groupData) {
         if (is_array($groupData)) {
             $arrAttributeOptions[] = array('pid' => $id, 'sorting' => 0, 'tstamp' => $time, 'ptable' => $ptable, 'type' => 'group', 'label' => $group, 'published' => 1);
             foreach ($groupData as $optionData) {
                 if (is_array($optionData)) {
                     //@todo if there are more options
                 } else {
                     $arrAttributeOptions[] = array('pid' => $id, 'sorting' => 0, 'tstamp' => $time, 'ptable' => $ptable, 'type' => 'option', 'label' => $optionData, 'published' => 1);
                 }
             }
         } else {
             $arrAttributeOptions[] = array('pid' => $id, 'sorting' => 0, 'tstamp' => $time, 'ptable' => $ptable, 'type' => 'option', 'label' => $groupData, 'published' => 1);
         }
     }
     $sorting = 0;
     foreach ($arrAttributeOptions as $arrData) {
         $objAttributeOption = new AttributeOption();
         $objAttributeOption->setRow($arrData);
         $objAttributeOption->sorting = $sorting;
         $objAttributeOption->save();
         $sorting += 128;
     }
     return true;
 }
Example #4
0
 /**
  * Modify DCA
  */
 public function checkPermission()
 {
     // Attribute options for products can always have a price
     if (\Input::get('do') != 'iso_products') {
         /** @type Attribute $objAttribute */
         $objAttribute = null;
         switch (\Input::get('act')) {
             case 'edit':
             case 'delete':
             case 'paste':
                 if (($objOption = AttributeOption::findByPk(\Input::get('id'))) !== null) {
                     $objAttribute = Attribute::findByPk($objOption->pid);
                 }
                 break;
             case '':
             case 'select':
             case 'editAll':
             case 'overwriteAll':
                 $objAttribute = Attribute::findByPk(\Input::get('id'));
                 break;
         }
         if (null === $objAttribute || $objAttribute->isVariantOption()) {
             unset($GLOBALS['TL_DCA'][AttributeOption::getTable()]['fields']['price']);
         }
     }
 }
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
     // Media Manager must fetch fallback
     $arrData['fields'][$this->field_name]['attributes']['fetch_fallback'] = true;
 }
Example #6
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $arrData['fields'][$this->field_name]['sql'] = "varchar(255) NOT NULL default ''";
     if ($this->fe_filter) {
         $arrData['config']['sql']['keys'][$this->field_name] = 'index';
     }
 }
Example #7
0
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     if ($this->rte == '') {
         return nl2br($objProduct->{$this->field_name});
     } else {
         return parent::generate($objProduct);
     }
 }
Example #8
0
 /**
  * Make sure array values are unserialized.
  *
  * @param IsotopeProduct $product
  *
  * @return mixed
  */
 public function getValue(IsotopeProduct $product)
 {
     $value = parent::getValue($product);
     if ('checkbox' === $this->fieldType) {
         $value = deserialize($value);
     }
     return (array) $value;
 }
 /**
  * Return list of MultiColumnWizard columns
  * @param   MultiColumnWizard
  * @return  array
  */
 public function getColumns($objWidget)
 {
     $arrColumns = array('value' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['value'], 'inputType' => 'text', 'eval' => array('class' => 'tl_text_2')), 'label' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['label'], 'inputType' => 'text', 'eval' => array('class' => 'tl_text_2')), 'default' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['default'], 'inputType' => 'checkbox', 'eval' => array('columnPos' => 2)), 'group' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['group'], 'inputType' => 'checkbox', 'eval' => array('columnPos' => 3)));
     if (($objAttribute = Attribute::findByPk($objWidget->activeRecord->id)) !== null && $objAttribute instanceof IsotopeAttributeWithOptions) {
         $arrColumns = $objAttribute->prepareOptionsWizard($objWidget, $arrColumns);
     }
     return $arrColumns;
 }
Example #10
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $arrData['fields'][$this->field_name]['sql'] = "binary(16) NULL";
     if ($this->fieldType == 'checkbox') {
         $arrData['fields'][$this->field_name]['eval']['multiple'] = true;
         $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
     }
 }
Example #11
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     unset($arrData['fields'][$this->field_name]['sql']);
     // An upload field is always customer defined
     $arrData['fields'][$this->field_name]['attributes']['customer_defined'] = true;
     // Install save_callback for upload widgets
     $arrData['fields'][$this->field_name]['save_callback'][] = array('Isotope\\Frontend', 'saveUpload');
 }
Example #12
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
     $arrData['fields'][$this->field_name]['eval']['fieldType'] = 'checkbox';
     $arrData['fields'][$this->field_name]['eval']['multiple'] = true;
     $arrData['fields'][$this->field_name]['eval']['files'] = true;
     $arrData['fields'][$this->field_name]['eval']['filesOnly'] = true;
     $arrData['fields'][$this->field_name]['eval']['extensions'] = 'mp4,m4v,mov,wmv,webm,ogv,m4a,mp3,wma,mpeg,wav,ogg,' . $GLOBALS['TL_CONFIG']['validImageTypes'];
 }
Example #13
0
 /**
  * Show price column in dcaWizard if attribute is not a variant option
  *
  * @param \Widget|object $objWidget
  *
  * @return string
  */
 public function initializeTableOptions(\Widget $objWidget)
 {
     /** @type Attribute $objAttribute */
     if (\Input::get('do') == 'iso_products') {
         $objAttribute = Attribute::findByFieldName($objWidget->name);
     } else {
         $objAttribute = Attribute::findByPk(\Input::get('id'));
     }
     if (null !== $objAttribute && !$objAttribute->isVariantOption()) {
         $objWidget->fields = array_merge($objWidget->fields, array('price'));
     }
     return AttributeOption::getTable();
 }
Example #14
0
 /**
  * Return list of default and widget legends
  * @param   Widget
  * @return  array
  */
 public function getLegends($objWidget)
 {
     $this->loadDataContainer(\Isotope\Model\Attribute::getTable());
     \System::loadLanguageFile(\Isotope\Model\Product::getTable());
     $arrLegends = $GLOBALS['TL_DCA'][\Isotope\Model\Attribute::getTable()]['fields']['legend']['options'];
     $arrLegends = array_intersect_key($GLOBALS['TL_LANG'][\Isotope\Model\Product::getTable()], array_flip($arrLegends));
     $varValue = $objWidget->value;
     if (!empty($varValue) && is_array($varValue)) {
         foreach ($varValue as $arrField) {
             if ($arrField['legend'] != '' && !isset($arrLegends[$arrField['legend']])) {
                 $arrLegends[$arrField['legend']] = $arrField['legend'];
             }
         }
     }
     return $arrLegends;
 }
Example #15
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
     if ($this->fieldType == 'checkbox') {
         $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
         $arrData['fields'][$this->field_name]['eval']['multiple'] = true;
         // Custom sorting
         if ($this->sortBy == 'custom') {
             $strOrderField = $this->field_name . '_order';
             $arrData['fields'][$this->field_name]['eval']['orderField'] = $strOrderField;
             $arrData['fields'][$strOrderField]['sql'] = "blob NULL";
         }
     } else {
         $arrData['fields'][$this->field_name]['sql'] = "binary(16) NULL";
         $arrData['fields'][$this->field_name]['eval']['multiple'] = false;
     }
 }
Example #16
0
 public function saveToDCA(array &$arrData)
 {
     // Varian select menu cannot have multiple option
     if ($this->isVariantOption()) {
         $this->multiple = false;
         $this->size = 1;
         $this->includeBlankOption = true;
     }
     parent::saveToDCA($arrData);
     if ($this->multiple) {
         $arrData['fields'][$this->field_name]['sql'] = "blob NULL";
     } else {
         $arrData['fields'][$this->field_name]['sql'] = "varchar(255) NOT NULL default ''";
         if ($this->fe_filter) {
             $arrData['config']['sql']['keys'][$this->field_name] = 'index';
         }
     }
 }
 /**
  * Constructor.
  *
  * @param object $objModule
  * @param string $strColumn
  */
 public function __construct($objModule, $strColumn = 'main')
 {
     parent::__construct($objModule, $strColumn);
     $this->iso_cumulativeFields = deserialize($this->iso_cumulativeFields);
     $fields = array();
     if (is_array($this->iso_cumulativeFields)) {
         foreach ($this->iso_cumulativeFields as $k => $v) {
             $attribute = $v['attribute'];
             unset($v['attribute']);
             $fields[$attribute] = $v;
         }
     }
     $this->iso_cumulativeFields = $fields;
     // Remove setting to prevent override of the module template
     $this->iso_filterTpl = '';
     $this->navigationTpl = $this->navigationTpl ?: 'nav_default';
     $this->activeFilters = Isotope::getRequestCache()->getFiltersForModules(array($this->id));
     // We cannot show matches if some of our filters are not applicable in SQL
     $dynamicFields = array_intersect(array_keys($this->iso_cumulativeFields), Attribute::getDynamicAttributeFields());
     $this->canShowMatches = empty($dynamicFields);
 }
Example #18
0
 /**
  * Generate header fields for product or variant
  * @param   array
  * @param   \Contao\DataContainer
  */
 public function headerFields($arrFields, $dc)
 {
     $t = Product::getTable();
     $arrNew = array();
     $objProduct = Product::findByPk($dc->id);
     if (null === $objProduct) {
         return $arrFields;
     }
     $arrAttributes = array('name', 'alias', 'sku');
     if ($objProduct->isVariant()) {
         $arrAttributes = array_merge($arrAttributes, array_intersect(array_merge($objProduct->getAttributes(), $objProduct->getVariantAttributes()), Attribute::getVariantOptionFields()));
     }
     foreach ($arrAttributes as $field) {
         $v = $objProduct->{$field};
         if ($v != '') {
             $arrNew[Format::dcaLabel($t, $field)] = Format::dcaValue($t, $field, $v);
         }
     }
     // Add fields that have potentially been added through the DCA, but do not allow to override the core fields
     return array_merge($arrNew, array_diff_key($arrFields, $arrNew));
 }
$GLOBALS['ISO_HOOKS']['postCheckout']['setSetQuantity'] = array('HeimrichHannot\\IsotopePlus\\IsotopePlus', 'setSetQuantity');
$GLOBALS['ISO_HOOKS']['updateItemInCollection']['validateStockCollectionUpdate'] = array('HeimrichHannot\\IsotopePlus\\IsotopePlus', 'validateStockCollectionUpdate');
$GLOBALS['ISO_HOOKS']['buttons'][] = array('HeimrichHannot\\IsotopePlus\\IsotopePlus', 'addDownloadSingleProductButton');
$GLOBALS['ISO_HOOKS']['preOrderStatusUpdate']['updateStock'] = array('HeimrichHannot\\IsotopePlus\\IsotopePlus', 'updateStock');
$GLOBALS['TL_HOOKS']['replaceDynamicScriptTags'][] = array('HeimrichHannot\\IsotopePlus\\IsotopePlus', 'hookReplaceDynamicScriptTags');
/**
 * Frontend modules
 */
$GLOBALS['FE_MOD']['isotopeplus'] = array('iso_productfilterplus' => 'Isotope\\Module\\ProductFilterPlus', 'iso_productlistplus' => 'Isotope\\Module\\ProductListPlus', 'iso_stockreport' => 'Isotope\\Module\\ModuleStockReport', 'iso_orderreport' => 'Isotope\\Module\\ModuleOrderReport', 'iso_cart_link' => 'HeimrichHannot\\IsotopePlus\\Module\\CartLink', 'iso_orderhistory_plus' => 'Isotope\\Module\\OrderHistoryPlus', 'iso_orderdetails_plus' => 'Isotope\\Module\\OrderDetailsPlus', 'iso_direct_checkout' => 'Isotope\\Module\\DirectCheckout', 'iso_product_ranking' => 'Isotope\\Module\\ProductRanking');
if (in_array('slick', \ModuleLoader::getActive())) {
    $GLOBALS['FE_MOD']['isotopeplus']['iso_productlistslick'] = 'Isotope\\Module\\ProductListSlick';
}
/**
 * Notification Center Notification Types
 */
if (in_array('notification_center_plus', \ModuleLoader::getActive())) {
    $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'][] = 'salutation_user';
    $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'][] = 'salutation_form';
    $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'][] = 'salutation_billing_address';
}
/**
 * Attributes
 */
\Isotope\Model\Attribute::registerModelType('youtube', 'Isotope\\Model\\Attribute\\Youtube');
/**
 * JS
 */
if (TL_MODE == 'FE') {
    $GLOBALS['TL_JAVASCRIPT']['tablesorter'] = 'assets/components/tablesorter/js/tablesorter.min.js|static';
    $GLOBALS['TL_JAVASCRIPT']['isotope_plus'] = 'system/modules/isotope_plus/assets/js/isotope_plus' . (!$GLOBALS['TL_CONFIG']['debugMode'] ? '.min' : '') . '.js|static';
}
Example #20
0
 /**
  * Return array of inherited attributes
  *
  * @return array
  */
 protected function getInheritedFields()
 {
     // Not a variant, no inherited fields
     if (!$this->isVariant()) {
         return array();
     }
     return array_merge(deserialize($this->arrData['inherit'], true), Attribute::getInheritFields());
 }
Example #21
0
/**
 * Notification Center notification types
 */
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'] = array('recipient_email');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['attachment_tokens'] = array('form_*', 'document');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'] = array('uniqid', 'order_status', 'order_status_old', 'order_status_id', 'order_status_id_old', 'recipient_email', 'order_id', 'order_items', 'order_products', 'order_subtotal', 'order_total', 'document_number', 'cart_html', 'cart_text', 'document', 'billing_address', 'billing_address_*', 'shipping_address', 'shipping_address_*', 'form_*', 'payment_id', 'payment_label', 'payment_note', 'shipping_id', 'shipping_label', 'shipping_note', 'config_*', 'member_*');
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_subject'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_html'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_text'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_replyTo'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_cc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
$GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['email_recipient_bcc'] =& $GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE']['isotope']['iso_order_status_change']['recipients'];
/**
 * Models
 */
$GLOBALS['TL_MODELS'][\Isotope\Model\Address::getTable()] = 'Isotope\\Model\\Address';
$GLOBALS['TL_MODELS'][\Isotope\Model\Attribute::getTable()] = 'Isotope\\Model\\Attribute';
$GLOBALS['TL_MODELS'][\Isotope\Model\BasePrice::getTable()] = 'Isotope\\Model\\BasePrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\Config::getTable()] = 'Isotope\\Model\\Config';
$GLOBALS['TL_MODELS'][\Isotope\Model\Document::getTable()] = 'Isotope\\Model\\Document';
$GLOBALS['TL_MODELS'][\Isotope\Model\Download::getTable()] = 'Isotope\\Model\\Download';
$GLOBALS['TL_MODELS'][\Isotope\Model\Gallery::getTable()] = 'Isotope\\Model\\Gallery';
$GLOBALS['TL_MODELS'][\Isotope\Model\Group::getTable()] = 'Isotope\\Model\\Group';
$GLOBALS['TL_MODELS'][\Isotope\Model\Label::getTable()] = 'Isotope\\Model\\Label';
$GLOBALS['TL_MODELS'][\Isotope\Model\OrderStatus::getTable()] = 'Isotope\\Model\\OrderStatus';
$GLOBALS['TL_MODELS'][\Isotope\Model\Payment::getTable()] = 'Isotope\\Model\\Payment';
$GLOBALS['TL_MODELS'][\Isotope\Model\Product::getTable()] = 'Isotope\\Model\\Product';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCategory::getTable()] = 'Isotope\\Model\\ProductCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollection::getTable()] = 'Isotope\\Model\\ProductCollection';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionDownload::getTable()] = 'Isotope\\Model\\ProductCollectionDownload';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionItem::getTable()] = 'Isotope\\Model\\ProductCollectionItem';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionSurcharge::getTable()] = 'Isotope\\Model\\ProductCollectionSurcharge';
 /**
  * Adjust DCA field for this attribute
  *
  * @param array $arrData
  */
 public function saveToDCA(array &$arrData)
 {
     if ($this->isCustomerDefined() && $this->optionsSource == 'product') {
         $this->be_filter = false;
         $this->fe_filter = false;
     }
     parent::saveToDCA($arrData);
     if (TL_MODE == 'BE') {
         if ($this->be_filter && \Input::get('act') == '') {
             $arrData['fields'][$this->field_name]['foreignKey'] = 'tl_iso_attribute_option.label';
         }
         if ($this->isCustomerDefined() && $this->optionsSource == 'product') {
             \Controller::loadDataContainer(static::$strTable);
             \System::loadLanguageFile(static::$strTable);
             $fieldTemplate = $GLOBALS['TL_DCA'][static::$strTable]['fields']['optionsTable'];
             unset($fieldTemplate['label']);
             $arrField = array_merge($arrData['fields'][$this->field_name], $fieldTemplate);
             $arrField['attributes']['dynamic'] = true;
             $arrField['foreignKey'] = 'tl_iso_attribute_option.label';
             if (\Input::get('do') == 'iso_products') {
                 $arrField['eval']['whereCondition'] = "field_name='{$this->field_name}'";
             }
             $arrData['fields'][$this->field_name] = $arrField;
         }
     }
 }
Example #23
0
 /**
  * Check if filter attribute is dynamic (can't use SQL filter then)
  * @return  bool
  */
 public function isMultilingualAttribute()
 {
     return in_array($this->arrConfig['attribute'], Attribute::getMultilingualFields());
 }
Example #24
0
 /**
  * Build a query based on the given options to count the number of products.
  *
  * @param array $arrOptions The options array
  *
  * @return string
  */
 protected static function buildCountQuery(array $arrOptions)
 {
     $hasTranslations = static::countTranslatedProducts() > 0;
     $hasVariants = ProductType::countByVariants() > 0;
     $arrJoins = array();
     $arrFields = array($arrOptions['table'] . ".*", "'" . str_replace('-', '_', $GLOBALS['TL_LANGUAGE']) . "' AS language");
     if ($hasVariants) {
         $arrFields[] = sprintf("IF(%s.pid>0, parent.type, %s.type) AS type", $arrOptions['table'], $arrOptions['table']);
     }
     if ($hasTranslations) {
         foreach (Attribute::getMultilingualFields() as $attribute) {
             $arrFields[] = "IFNULL(translation.{$attribute}, " . $arrOptions['table'] . ".{$attribute}) AS {$attribute}";
         }
     }
     $arrJoins[] = sprintf(" LEFT OUTER JOIN %s c ON %s.id=c.pid", ProductCategory::getTable(), $arrOptions['table']);
     if ($hasTranslations) {
         $arrJoins[] = sprintf(" LEFT OUTER JOIN %s translation ON %s.id=translation.pid AND translation.language='%s'", $arrOptions['table'], $arrOptions['table'], str_replace('-', '_', $GLOBALS['TL_LANGUAGE']));
     }
     if ($hasVariants) {
         $arrJoins[] = sprintf(" LEFT OUTER JOIN %s parent ON %s.pid=parent.id", $arrOptions['table'], $arrOptions['table']);
     }
     // Generate the query
     $strWhere = '';
     $strQuery = "\n            SELECT\n                " . implode(', ', $arrFields) . ",\n                COUNT(DISTINCT " . $arrOptions['table'] . ".id) AS count\n            FROM " . $arrOptions['table'] . implode("", $arrJoins);
     // Where condition
     if (!empty($arrOptions['column'])) {
         if (!is_array($arrOptions['column'])) {
             $arrOptions['column'] = array($arrOptions['table'] . '.' . $arrOptions['column'] . '=?');
         }
         $strWhere = " AND " . implode(" AND ", $arrOptions['column']);
     }
     // The model must never find a language record
     $strQuery .= " WHERE {$arrOptions['table']}.language=''" . $strWhere;
     // Group by
     if ($arrOptions['group'] !== null) {
         $strQuery .= " GROUP BY " . $arrOptions['group'];
     }
     return $strQuery;
 }
Example #25
0
 /**
  * Return select statement to load product data including multilingual fields
  * @param array an array of columns
  * @return string
  */
 protected static function buildFindQuery(array $arrOptions)
 {
     $objBase = new \DcaExtractor($arrOptions['table']);
     $arrJoins = array();
     $arrFields = array($arrOptions['table'] . ".*", "IF(" . $arrOptions['table'] . ".pid>0, parent.type, " . $arrOptions['table'] . ".type) AS type", "'" . str_replace('-', '_', $GLOBALS['TL_LANGUAGE']) . "' AS language");
     foreach (Attribute::getMultilingualFields() as $attribute) {
         $arrFields[] = "IFNULL(translation.{$attribute}, " . $arrOptions['table'] . ".{$attribute}) AS {$attribute}";
     }
     foreach (Attribute::getFetchFallbackFields() as $attribute) {
         $arrFields[] = "{$arrOptions['table']}.{$attribute} AS {$attribute}_fallback";
     }
     $arrFields[] = "c.sorting";
     $arrJoins[] = " LEFT OUTER JOIN " . \Isotope\Model\ProductCategory::getTable() . " c ON {$arrOptions['table']}.id=c.pid";
     $arrJoins[] = " LEFT OUTER JOIN " . $arrOptions['table'] . " translation ON " . $arrOptions['table'] . ".id=translation.pid AND translation.language='" . str_replace('-', '_', $GLOBALS['TL_LANGUAGE']) . "'";
     $arrJoins[] = " LEFT OUTER JOIN " . $arrOptions['table'] . " parent ON " . $arrOptions['table'] . ".pid=parent.id";
     if ($objBase->hasRelations()) {
         $intCount = 0;
         foreach ($objBase->getRelations() as $strKey => $arrConfig) {
             // Automatically join the single-relation records
             if ($arrConfig['load'] == 'eager' || $arrOptions['eager']) {
                 if ($arrConfig['type'] == 'hasOne' || $arrConfig['type'] == 'belongsTo') {
                     if (is_array($arrOptions['joinAliases']) && ($key = array_search($arrConfig['table'], $arrOptions['joinAliases'])) !== false) {
                         $strJoinAlias = $key;
                         unset($arrOptions['joinAliases'][$key]);
                     } else {
                         ++$intCount;
                         $strJoinAlias = 'j' . $intCount;
                     }
                     $objRelated = new \DcaExtractor($arrConfig['table']);
                     foreach (array_keys($objRelated->getFields()) as $strField) {
                         $arrFields[] = $strJoinAlias . '.' . $strField . ' AS ' . $strKey . '__' . $strField;
                     }
                     $arrJoins[] = " LEFT JOIN " . $arrConfig['table'] . " {$strJoinAlias} ON " . $arrOptions['table'] . "." . $strKey . "={$strJoinAlias}.id";
                 }
             }
         }
     }
     // Generate the query
     $strQuery = "SELECT " . implode(', ', $arrFields) . " FROM " . $arrOptions['table'] . implode("", $arrJoins);
     // Where condition
     if (!is_array($arrOptions['column'])) {
         $arrOptions['column'] = array($arrOptions['table'] . '.' . $arrOptions['column'] . '=?');
     }
     // The model must never find a language record
     $strQuery .= " WHERE {$arrOptions['table']}.language='' AND " . implode(" AND ", $arrOptions['column']);
     // Group by
     if ($arrOptions['group'] !== null) {
         $strQuery .= " GROUP BY " . $arrOptions['group'];
     }
     // Order by
     if ($arrOptions['order'] !== null) {
         $strQuery .= " ORDER BY " . $arrOptions['order'];
     }
     return $strQuery;
 }
Example #26
0
 public function saveToDCA(array &$arrData)
 {
     parent::saveToDCA($arrData);
     $maxlength = (int) $this->maxlength ?: 255;
     $arrData['fields'][$this->field_name]['sql'] = "varchar({$maxlength}) NOT NULL default ''";
 }
Example #27
0
<?php

/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Load tl_iso_product language file for field legends
 */
\System::loadLanguageFile('tl_iso_product');
/**
 * Table tl_iso_attribute
 */
$GLOBALS['TL_DCA']['tl_iso_attribute'] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => true, 'closed' => true, 'onload_callback' => array(array('Isotope\\Backend', 'initializeSetupModule'), array('Isotope\\Backend\\Attribute\\Callback', 'disableFieldName'), array('Isotope\\Backend\\Attribute\\Callback', 'prepareForVariantOptions')), 'onsubmit_callback' => array(array('Isotope\\Backend\\Attribute\\Callback', 'updateDatabase')), 'sql' => array('keys' => array('id' => 'primary', 'type' => 'index'))), 'list' => array('sorting' => array('mode' => 1, 'fields' => array('legend', 'name'), 'flag' => 1, 'panelLayout' => 'sort,filter,search,limit'), 'label' => array('fields' => array('name', 'field_name', 'type'), 'format' => '<div style="float:left; width:200px">%s</div><div style="float:left; width:200px; color:#b3b3b3;">%s</div><div style="color:#b3b3b3">[%s]</div>'), 'global_operations' => array('back' => array('label' => &$GLOBALS['TL_LANG']['MSC']['backBT'], 'href' => 'mod=&table=', 'class' => 'header_back', 'attributes' => 'onclick="Backend.getScrollOffset();"'), 'new' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['new'], 'href' => 'act=create', 'class' => 'header_new', 'attributes' => 'onclick="Backend.getScrollOffset();"'), 'all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'copy' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['copy'], 'href' => 'act=copy', 'icon' => 'copy.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['tl_iso_attribute']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['show'], 'href' => 'act=show', 'icon' => 'show.gif'))), 'palettes' => array('__selector__' => array('type', 'variant_option', 'storeFile', 'files'), 'default' => '{attribute_legend},name,field_name,type,legend', 'text' => '{attribute_legend},name,field_name,type,legend,customer_defined;{description_legend:hide},description;{config_legend},rgxp,maxlength,mandatory,multilingual,datepicker;{search_filters_legend},fe_search,fe_sorting,be_search', 'textarea' => '{attribute_legend},name,field_name,type,legend,customer_defined;{description_legend:hide},description;{config_legend},rgxp,rte,mandatory,multilingual;{search_filters_legend},fe_search,fe_sorting,be_search', 'select' => '{attribute_legend},name,field_name,type,legend,variant_option,customer_defined;{description_legend:hide},description;{options_legend},options,foreignKey;{config_legend},mandatory,multiple,size;{search_filters_legend},fe_filter,fe_sorting,be_filter,fe_search', 'selectvariant_option' => '{attribute_legend},name,field_name,type,legend,variant_option;{description_legend:hide},description;{options_legend},options,foreignKey;{search_filters_legend},fe_filter,fe_sorting,be_filter', 'radio' => '{attribute_legend},name,field_name,type,legend,variant_option,customer_defined;{description_legend:hide},description;{options_legend},options,foreignKey;{config_legend},mandatory;{search_filters_legend},fe_filter,fe_sorting', 'radiovariant_option' => '{attribute_legend},name,field_name,type,legend,variant_option;{description_legend:hide},description;{options_legend},options,foreignKey;{search_filters_legend},fe_filter,fe_sorting,be_filter', 'checkbox' => '{attribute_legend},name,field_name,type,legend,customer_defined;{description_legend:hide},description;{options_legend},options,foreignKey;{config_legend},mandatory,multiple;{search_filters_legend},fe_filter,fe_sorting', 'conditionalselect' => '{attribute_legend},name,field_name,type,legend,customer_defined;{description_legend:hide},description;{options_legend},options,foreignKey;{config_legend},mandatory,multiple,size,conditionField;{search_filters_legend},fe_filter,fe_sorting', 'mediaManager' => '{attribute_legend},name,field_name,type,legend;{description_legend:hide},description;{config_legend},extensions,mandatory', 'fileTree' => '{attribute_legend},name,field_name,type,legend;{description_legend:hide},description;{config_legend},fieldType,path,mandatory,files', 'downloads' => '{attribute_legend},name,field_name,type,legend;{description_legend:hide},description;{config_legend},fieldType,sortBy,path,mandatory,files', 'upload' => '{attribute_legend},name,field_name,type,legend;{description_legend:hide},description;{config_legend},extensions,maxlength,mandatory;{store_legend:hide},storeFile'), 'subpalettes' => array('storeFile' => 'uploadFolder,useHomeDir,doNotOverwrite', 'files' => 'extensions,filesOnly'), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'name' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['name'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'field_name' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['field_name'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 30, 'unique' => true, 'doNotCopy' => true, 'doNotSaveEmpty' => true, 'tl_class' => 'w50'), 'sql' => "varchar(30) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend\\Attribute\\Callback', 'validateFieldName'))), 'type' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['type'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => function () {
    return \Isotope\Model\Attribute::getModelTypeOptions();
}, 'eval' => array('mandatory' => true, 'includeBlankOption' => true, 'submitOnChange' => true, 'helpwizard' => true, 'tl_class' => 'w50', 'chosen' => true), 'reference' => &$GLOBALS['TL_LANG']['ATTR'], 'sql' => "varchar(64) NOT NULL default ''"), 'legend' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['legend'], 'exclude' => true, 'default' => 'options_legend', 'inputType' => 'select', 'options' => array('general_legend', 'meta_legend', 'pricing_legend', 'inventory_legend', 'shipping_legend', 'options_legend', 'media_legend', 'expert_legend', 'publish_legend'), 'reference' => &$GLOBALS['TL_LANG']['tl_iso_product'], 'eval' => array('mandatory' => true, 'tl_class' => 'w50', 'chosen' => true), 'sql' => "varchar(255) NOT NULL default ''"), 'description' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['description'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'clr long'), 'sql' => "varchar(255) NOT NULL default ''"), 'options' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options'], 'exclude' => true, 'inputType' => 'multiColumnWizard', 'eval' => array('tl_class' => 'clr', 'columnFields' => array('value' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['value'], 'inputType' => 'text', 'eval' => array('class' => 'tl_text_2')), 'label' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['label'], 'inputType' => 'text', 'eval' => array('class' => 'tl_text_2')), 'default' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['default'], 'inputType' => 'checkbox', 'eval' => array('columnPos' => 2)), 'group' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['options']['group'], 'inputType' => 'checkbox', 'eval' => array('columnPos' => 3)))), 'sql' => "blob NULL"), 'foreignKey' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['foreignKey'], 'exclude' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:80px', 'decodeEntities' => true), 'sql' => "text NULL", 'save_callback' => array(array('Isotope\\Backend\\Attribute\\Callback', 'validateForeignKey'))), 'variant_option' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['variant_option'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'be_search' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['be_search'], 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''"), 'be_filter' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['be_filter'], 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''"), 'customer_defined' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['customer_defined'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'mandatory' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['mandatory'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'fe_filter' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['fe_filter'], 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''"), 'fe_search' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['fe_search'], 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''"), 'fe_sorting' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['fe_sorting'], 'exclude' => true, 'inputType' => 'checkbox', 'sql' => "char(1) NOT NULL default ''"), 'multiple' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['multiple'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'size' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['size'], 'exclude' => true, 'inputType' => 'text', 'default' => 5, 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'"), 'extensions' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['extensions'], 'exclude' => true, 'default' => 'jpg,jpeg,gif,png', 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'extnd', 'maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'rte' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['rte'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\Attribute\\Callback', 'getRTE'), 'eval' => array('includeBlankOption' => true, 'tl_class' => 'w50', 'chosen' => true), 'sql' => "varchar(255) NOT NULL default ''"), 'multilingual' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['multilingual'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'rgxp' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['rgxp'], 'exclude' => true, 'inputType' => 'select', 'options' => array('digit', 'alpha', 'alnum', 'extnd', 'date', 'time', 'datim', 'phone', 'email', 'url', 'price', 'discount', 'surcharge'), 'reference' => &$GLOBALS['TL_LANG']['tl_iso_attribute'], 'eval' => array('helpwizard' => true, 'includeBlankOption' => true, 'tl_class' => 'w50', 'chosen' => true), 'sql' => "varchar(255) NOT NULL default ''"), 'maxlength' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['maxlength'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'conditionField' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['conditionField'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\Attribute\\Callback', 'getConditionFields'), 'eval' => array('includeBlankOption' => true, 'mandatory' => true, 'tl_class' => 'w50', 'chosen' => true), 'sql' => "varchar(30) NOT NULL default ''"), 'fieldType' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['fieldType'], 'exclude' => true, 'inputType' => 'select', 'options' => array('checkbox', 'radio'), 'reference' => &$GLOBALS['TL_LANG']['tl_iso_attribute'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(8) NOT NULL default ''"), 'files' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['files'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'filesOnly' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['filesOnly'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50 m12'), 'sql' => "char(1) NOT NULL default ''"), 'sortBy' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['sortBy'], 'exclude' => true, 'inputType' => 'select', 'options' => array('custom', 'name_asc', 'name_desc', 'date_asc', 'date_desc', 'random'), 'reference' => &$GLOBALS['TL_LANG']['tl_iso_attribute'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(32) NOT NULL default ''"), 'path' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['path'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'sql' => "binary(16) NULL"), 'storeFile' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['storeFile'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true), 'sql' => "char(1) NOT NULL default ''"), 'uploadFolder' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['uploadFolder'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'sql' => "binary(16) NULL"), 'useHomeDir' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['useHomeDir'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'doNotOverwrite' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['doNotOverwrite'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'datepicker' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_attribute']['datepicker'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend\\Attribute\\Callback', 'validateDatepicker')))));
Example #28
0
 /**
  * Calculate price surcharge for attribute options
  *
  * @param float  $fltPrice
  * @param object $objSource
  * @param string $strField
  * @param int    $intTaxClass
  * @param array  $arrOptions
  *
  * @return float
  * @throws \Exception
  */
 public function addOptionsPrice($fltPrice, $objSource, $strField, $intTaxClass, array $arrOptions)
 {
     $fltAmount = $fltPrice;
     if ($objSource instanceof IsotopePrice && ($objProduct = $objSource->getRelated('pid')) !== null) {
         /** @type IsotopeProduct|Standard $objProduct */
         $arrAttributes = array_intersect(Attribute::getPricedFields(), array_merge($objProduct->getAttributes(), $objProduct->getVariantAttributes()));
         foreach ($arrAttributes as $field) {
             if (($objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$field]) !== null && $objAttribute instanceof IsotopeAttributeWithOptions && $objAttribute->canHavePrices() && ($objOptions = $objAttribute->getOptionsFromManager($objProduct)) !== null) {
                 $value = $objAttribute->isCustomerDefined() ? $arrOptions[$field] : $objProduct->{$field};
                 $value = deserialize($value, true);
                 /** @type AttributeOption $objOption */
                 foreach ($objOptions as $objOption) {
                     if (in_array($objOption->id, $value)) {
                         $fltAmount += $objOption->getAmount($fltPrice, $objSource->tax_class);
                     }
                 }
             }
         }
     }
     return $fltAmount;
 }
Example #29
0
 /**
  * Add options from attribute to DCA
  *
  * @param array  $arrData
  * @param object $objDca
  *
  * @return array
  */
 public function addOptionsFromAttribute($arrData, $objDca)
 {
     if ($arrData['strTable'] == Product::getTable() && $arrData['optionsSource'] != '' && $arrData['optionsSource'] != 'foreignKey') {
         /** @var IsotopeAttributeWithOptions|Attribute $objAttribute */
         $objAttribute = Attribute::findByFieldName($arrData['strField']);
         if (null !== $objAttribute && $objAttribute instanceof IsotopeAttributeWithOptions) {
             $arrOptions = $objDca instanceof IsotopeProduct ? $objAttribute->getOptionsForWidget($objDca) : $objAttribute->getOptionsForWidget();
             if (!empty($arrOptions)) {
                 if ($arrData['includeBlankOption']) {
                     array_unshift($arrOptions, array('value' => '', 'label' => $arrData['blankOptionLabel'] ?: '-'));
                 }
                 $arrData['options'] = $arrOptions;
                 if (null !== $arrData['default']) {
                     $arrDefault = array_filter($arrOptions, function (&$option) {
                         return (bool) $option['default'];
                     });
                     if (!empty($arrDefault)) {
                         array_walk($arrDefault, function (&$value) {
                             $value = $value['value'];
                         });
                         $arrData['value'] = $objAttribute->multiple ? $arrDefault : $arrDefault[0];
                     }
                 }
             }
         }
     }
     return $arrData;
 }
 /**
  * Get formatted label for the attribute option
  *
  * @param IsotopeProduct $objProduct
  *
  * @return string
  */
 public function getLabel(IsotopeProduct $objProduct = null)
 {
     $strLabel = $this->label;
     /** @type Attribute $objAttribute */
     $objAttribute = null;
     switch ($this->ptable) {
         case 'tl_iso_product':
             $objAttribute = Attribute::findByFieldName($this->field_name);
             break;
         case 'tl_iso_attribute':
             $objAttribute = Attribute::findByPk($this->pid);
             break;
     }
     if (null !== $objAttribute && !$objAttribute->isVariantOption() && $this->price != '') {
         $strLabel .= ' (';
         if (!$this->isPercentage() || null !== $objProduct) {
             $strPrice = Isotope::formatPriceWithCurrency($this->getPrice($objProduct), false);
         } else {
             $strPrice = $this->price;
         }
         $strLabel .= $this->isFromPrice($objProduct) ? sprintf($GLOBALS['TL_LANG']['MSC']['priceRangeLabel'], $strPrice) : $strPrice;
         $strLabel .= ')';
     }
     return $strLabel;
 }