/** * Set SQL field for this attribute * @param arary */ 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'; } }
/** * Set SQL field for this attribute * @param array */ public function saveToDCA(array &$arrData) { parent::saveToDCA($arrData); if ($this->multiple) { $arrData['fields'][$this->field_name]['sql'] = "blob NULL"; } else { $arrData['fields'][$this->field_name]['sql'] = "char(1) NOT NULL default ''"; } }
/** * Set SQL field for this attribute * @param arary */ public function saveToDCA(array &$arrData) { $this->multiple = false; parent::saveToDCA($arrData); if ('attribute' === $this->optionsSource) { $arrData['fields'][$this->field_name]['sql'] = "varchar(255) NOT NULL default ''"; } else { $arrData['fields'][$this->field_name]['sql'] = "int(10) NOT NULL default '0'"; } if ($this->fe_filter) { $arrData['config']['sql']['keys'][$this->field_name] = 'index'; } }
/** * Adjust DCA field for this attribute * @param arary */ public function saveToDCA(array &$arrData) { // Varian select menu cannot have multiple option if ($this->isVariantOption()) { $this->multiple = false; $this->size = 1; } 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'; } } }
/** * Set SQL field for this attribute * @param array */ public function saveToDCA(array &$arrData) { parent::saveToDCA($arrData); $arrData['fields'][$this->field_name]['sql'] = "blob NULL"; }
/** * Alter the options and set an image as label * * @param IsotopeProduct|Product\Standard $objProduct * * @return array|mixed * * @throws \InvalidArgumentException when optionsSource=product but product is null * @throws \UnexpectedValueException for unknown optionsSource */ public function getOptionsForWidget(IsotopeProduct $objProduct = null) { // Skip in the back end or without a given product if (TL_MODE == 'BE' || null === $objProduct) { return parent::getOptionsForWidget($objProduct); } // Fetch all product's variants and make the accessible via the attribute value in an array $objVariants = Product::findAvailableByIds($objProduct->getVariantIds()); if (null === $objVariants) { return parent::getOptionsForWidget($objProduct); } /** @var IsotopeProduct[] $arrVariants */ $arrVariants = array_combine($objVariants->fetchEach($this->field_name), $objVariants->getModels()); // Alter the options return array_map(function ($arrOption) use($arrVariants) { // Skip if option has no associated product variant if (!array_key_exists($arrOption['value'], $arrVariants)) { return $arrOption; } /** @var Gallery|Gallery\Standard $objGallery */ $objGallery = Gallery::createForProductAttribute($arrVariants[$arrOption['value']], 'images', array('gallery' => $this->radioImageGallery)); // Wrap label in span with css class $arrOption['label'] = sprintf('<span class="attribute-label">%s</span>', $arrOption['label']); // Add image to label $arrOption['label'] .= PHP_EOL . $objGallery->generateMainImage(); return $arrOption; }, parent::getOptionsForWidget($objProduct)); }