本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute_Abstract::usesSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute_Abstract::usesSource方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute_Abstract::usesSource怎么用?PHP Mage_Eav_Model_Entity_Attribute_Abstract::usesSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Attribute_Abstract
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute_Abstract::usesSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getAttributeType
/**
* Get attribute type for upcoming validation.
*
* @param Mage_Eav_Model_Entity_Attribute_Abstract|Mage_Eav_Model_Entity_Attribute $attribute
* @return string
*/
public static function getAttributeType(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
{
if ($attribute->usesSource()) {
return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select';
} elseif ($attribute->isStatic()) {
return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar';
} else {
return $attribute->getBackendType();
}
}
示例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';
/* 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;
}