当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractAttribute::getFrontendInput方法代码示例

本文整理汇总了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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:EavValidationRules.php

示例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();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:Import.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:25,代码来源:Options.php

示例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() != "";
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Attribute.php

示例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();
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:Import.php


注:本文中的Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getFrontendInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。