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


PHP Mage_Eav_Model_Entity_Attribute_Abstract::getSource方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Abstract::getSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Abstract::getSource方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getSource怎么用?PHP Mage_Eav_Model_Entity_Attribute_Abstract::getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Attribute_Abstract的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Abstract::getSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setPricingLabelFromAttribute

 public function setPricingLabelFromAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     if ($attribute->getSource()) {
         $this->setLabel($attribute->getSource()->getOptionText($this->getValueIndex()));
     } else {
         $this->setLabel($this->getValueIndex());
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:9,代码来源:Pricing.php

示例2: getAttributeSelectElement

 /**
  * Build attribute select element html string
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return string
  */
 public function getAttributeSelectElement($attribute)
 {
     $extra = '';
     $options = $attribute->getSource()->getAllOptions(false);
     $name = $attribute->getAttributeCode();
     // 2 - avoid yes/no selects to be multiselects
     if (is_array($options) && count($options) > 2) {
         $extra = 'multiple="multiple" size="4"';
         $name .= '[]';
     } else {
         array_unshift($options, array('value' => '', 'label' => Mage::helper('catalogsearch')->__('All')));
     }
     return $this->_getSelectBlock()->setName($name)->setId($attribute->getAttributeCode())->setTitle($this->getAttributeLabel($attribute))->setExtraParams($extra)->setValue($this->getAttributeValue($attribute))->setOptions($options)->setClass('multiselect')->getHtml();
 }
开发者ID:blazeriaz,项目名称:youguess,代码行数:20,代码来源:Form.php

示例3: getAttributeOptions

 /**
  * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return array
  */
 public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     $options = array();
     if ($attribute->usesSource()) {
         // should attribute has index (option value) instead of a label?
         $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
         // only default (admin) store values used
         $attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
         try {
             foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                 foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
                     if (strlen($innerOption['value'])) {
                         // skip ' -- Please Select -- ' option
                         $options[$innerOption['value']] = $innerOption[$index];
                     }
                 }
             }
         } catch (Exception $e) {
             // ignore exceptions connected with source models
         }
     }
     return $options;
 }
开发者ID:blazeriaz,项目名称:youguess,代码行数:29,代码来源:Abstract.php

示例4: _validateAttributeWithSource

 /**
  * Validate attribute value for attributes with source models
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $attrValue
  * @return array|bool
  */
 protected function _validateAttributeWithSource(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $attrValue)
 {
     $errors = array();
     // validate attributes with source models
     if (null !== $attrValue && $attribute->getSourceModel()) {
         if ('multiselect' !== $attribute->getFrontendInput() && is_array($attrValue)) {
             return array('Invalid value type for ' . $attribute->getAttributeCode());
         }
         $possibleValues = $attribute->getSource()->getAllOptions(false);
         foreach ((array) $attrValue as $value) {
             if (is_scalar($value)) {
                 $value = (string) $value;
                 $isValid = false;
                 foreach ($possibleValues as $optionData) {
                     // comparison without types check is performed only when both values are numeric
                     $useStrictMode = !(is_numeric($value) && is_numeric($optionData['value']));
                     $isValid = $useStrictMode ? $value === $optionData['value'] : $value == $optionData['value'];
                     if ($isValid) {
                         break;
                     }
                 }
                 if (!$isValid) {
                     $errors[] = 'Invalid value "' . $value . '" for ' . $attribute->getAttributeCode();
                 }
             } else {
                 $errors[] = 'Invalid value type for ' . $attribute->getAttributeCode();
             }
         }
     }
     return $errors ? $errors : true;
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:38,代码来源:Eav.php

示例5: getAttributeOptions

 /**
  * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return array
  */
 public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     $options = array();
     if ($attribute->usesSource()) {
         // should attribute has index (option value) instead of a label?
         $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
         /* MEP changed admin store to current profile store id */
         $attribute->setStoreId($this->getProfile()->getStoreId());
         try {
             foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                 foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
                     if (strlen($innerOption['value'])) {
                         // skip ' -- Please Select -- ' option
                         $options[$innerOption['value']] = $innerOption[$index];
                     }
                 }
             }
         } catch (Exception $e) {
             // ignore exceptions connected with source models
         }
     }
     return $options;
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:29,代码来源:Product.php


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