本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getFrontendInput方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAttribute::getFrontendInput方法的具体用法?PHP AbstractAttribute::getFrontendInput怎么用?PHP AbstractAttribute::getFrontendInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Eav\Model\Entity\Attribute\AbstractAttribute
的用法示例。
在下文中一共展示了AbstractAttribute::getFrontendInput方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Build validation rules
*
* @param AbstractAttribute $attribute
* @param array $data
* @return array
*/
public function build(AbstractAttribute $attribute, array $data)
{
$validation = [];
if (isset($data['required']) && $data['required'] == 1) {
$validation = array_merge($validation, ['required-entry' => true]);
}
if ($attribute->getFrontendInput() === 'price') {
$validation = array_merge($validation, ['validate-zero-or-greater' => true]);
}
if ($attribute->getValidateRules()) {
$validation = array_merge($validation, $attribute->getValidateRules());
}
$rules = [];
foreach ($validation as $type => $ruleName) {
$rule = [$type => $ruleName];
if ($type === 'input_validation') {
$rule = isset($this->validationRules[$ruleName]) ? $this->validationRules[$ruleName] : [];
}
$rules = array_merge($rules, $rule);
}
return $rules;
}
示例2: getAttributeType
/**
* Get attribute type for upcoming validation.
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\Magento\Eav\Model\Entity\Attribute $attribute
* @return string
*/
public static function getAttributeType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
{
$frontendInput = $attribute->getFrontendInput();
if ($attribute->usesSource() && in_array($frontendInput, ['select', 'multiselect', 'boolean'])) {
return $frontendInput;
} elseif ($attribute->isStatic()) {
return $frontendInput == 'date' ? 'datetime' : 'varchar';
} else {
return $attribute->getBackendType();
}
}
示例3: _prepareOptionValues
/**
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @param array|\Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection $optionCollection
* @return array
*/
protected function _prepareOptionValues(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $optionCollection)
{
$type = $attribute->getFrontendInput();
if ($type === 'select' || $type === 'multiselect') {
$defaultValues = explode(',', $attribute->getDefaultValue());
$inputType = $type === 'select' ? 'radio' : 'checkbox';
} else {
$defaultValues = [];
$inputType = '';
}
$values = [];
$isSystemAttribute = is_array($optionCollection);
foreach ($optionCollection as $option) {
$bunch = $isSystemAttribute ? $this->_prepareSystemAttributeOptionValues($option, $inputType, $defaultValues) : $this->_prepareUserDefinedAttributeOptionValues($option, $inputType, $defaultValues);
foreach ($bunch as $value) {
$values[] = new \Magento\Framework\Object($value);
}
}
return $values;
}
示例4: _isAllowedAttribute
/**
* Check if attribute allowed
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @return bool
*/
protected function _isAllowedAttribute($attribute)
{
return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes) && $attribute->getFrontendLabel() != "";
}
示例5: getAttributeType
/**
* Get attribute type for upcoming validation.
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\Magento\Eav\Model\Entity\Attribute $attribute
* @return string
*/
public static function getAttributeType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
{
if ($attribute->usesSource()) {
return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select';
} elseif ($attribute->isStatic()) {
return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar';
} else {
return $attribute->getBackendType();
}
}