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


PHP Mage_Catalog_Model_Resource_Eav_Attribute::getAttributeCode方法代码示例

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


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

示例1: overrideAttribute

 public function overrideAttribute(Mage_Catalog_Model_Resource_Eav_Attribute $attribute)
 {
     if (!empty($this->_attributeOverrides[$attribute->getAttributeCode()])) {
         $data = $this->_attributeOverrides[$attribute->getAttributeCode()];
         if (isset($data['options_method']) && method_exists($this, $data['options_method'])) {
             $data['filter_options'] = $this->{$data['options_method']}();
         }
         $attribute->addData($data);
         return true;
     }
     return false;
 }
开发者ID:Inchoo,项目名称:Inchoo_PHP7,代码行数:12,代码来源:Configurable.php

示例2: addPriceFilter

 /**
  * Add filter by attribute price
  *
  * @param Mage_CatalogSearch_Model_Advanced $object
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string|array $value
  */
 public function addPriceFilter($object, $attribute, $value)
 {
     if (empty($value['from']) && empty($value['to'])) {
         return false;
     }
     if (Mage::helper('solr')->isEnabled()) {
         $typeConverter = new DMC_Solr_Model_SolrServer_Adapter_Product_TypeConverter();
         $code = $attribute->getAttributeCode();
         $items = $typeConverter->getItems();
         $select = $object->getProductCollection()->getSelect();
         $rate = 1;
         if (!empty($value['currency'])) {
             $rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
         }
         if (strlen($value['from']) > 0) {
             $from = $value['from'] * $rate;
         } else {
             $from = 0;
         }
         if (strlen($value['to']) > 0) {
             $to = $value['to'] * $rate;
         } else {
             $to = 99999999;
         }
         $select->where($items[$attribute->getFrontend()->getInputType()]['solr_index_prefix'] . $typeConverter::SUBPREFIX_INDEX . 'price:[' . $from . ' TO ' . $to . ']');
     } else {
         $adapter = $this->_getReadAdapter();
         $conditions = array();
         if (strlen($value['from']) > 0) {
             $conditions[] = $adapter->quoteInto('price_index.min_price %s * %s >= ?', $value['from']);
         }
         if (strlen($value['to']) > 0) {
             $conditions[] = $adapter->quoteInto('price_index.min_price %s * %s <= ?', $value['to']);
         }
         if (!$conditions) {
             return false;
         }
         $object->getProductCollection()->addPriceData();
         $select = $object->getProductCollection()->getSelect();
         $response = $this->_dispatchPreparePriceEvent($select);
         $additional = join('', $response->getAdditionalCalculations());
         $rate = 1;
         if (!empty($value['currency'])) {
             $rate = Mage::app()->getStore()->getBaseCurrency()->getRate($value['currency']);
         }
         foreach ($conditions as $condition) {
             $select->where(sprintf($condition, $additional, $rate));
         }
     }
     return true;
 }
开发者ID:kevinrademan,项目名称:Magento-Solr,代码行数:58,代码来源:Advanced.php

示例3: addSearchParams

 /**
  * Append search params to the form
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
  * @param Varien_Data_Form                          $form      Form the
  *
  * @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
  */
 public function addSearchParams($attribute, $form)
 {
     $fieldset = $this->_getFieldset($form);
     $fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'default' => 1), 'is_searchable');
     $fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
     $fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
     $fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
     $fieldset->addField('fuzziness_value', 'text', array('name' => 'fuzziness_value', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzziness'), 'class' => 'validate-number validate-number-range number-range-0-1', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 1.'), Mage::helper('smile_elasticsearch')->__('See doc at <a href="%s" target="_blank">here</a> for more information', 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/common-options.html#_string_fields')))), 'is_fuzziness_enabled');
     $fieldset->addField('fuzziness_prefix_length', 'text', array('name' => 'fuzziness_prefix_length', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzzy prefix range'), 'class' => 'validate-digits validate-digits-range digits-range-0-9', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 9.'), Mage::helper('smile_elasticsearch')->__('Min.common prefix between original term and fuzzy matched one.')))), 'fuzziness_value');
     if ($attribute->getAttributeCode() == 'name') {
         $form->getElement('is_searchable')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setValue(1);
     }
     return $this;
 }
开发者ID:ngocdb,项目名称:smile-magento-elasticsearch,代码行数:24,代码来源:Search.php

示例4: _getSearchParam

 /**
  * Retrieve filter array
  *
  * @param Enterprise_Search_Model_Resource_Collection $collection
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string|array $value
  * @return array
  */
 protected function _getSearchParam($collection, $attribute, $value)
 {
     if (empty($value) || isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         return false;
     }
     $localeCode = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
     $languageCode = Mage::helper('enterprise_search')->getLanguageCodeByLocaleCode($localeCode);
     $languageSuffix = $languageCode ? '_' . $languageCode : '';
     $field = $attribute->getAttributeCode();
     $backendType = $attribute->getBackendType();
     $frontendInput = $attribute->getFrontendInput();
     if ($frontendInput == 'multiselect') {
         $field = 'attr_multi_' . $field;
     } elseif ($frontendInput == 'select' || $frontendInput == 'boolean') {
         $field = 'attr_select_' . $field;
     } elseif ($backendType == 'decimal') {
         $field = 'attr_decimal_' . $field;
     } elseif ($backendType == 'datetime') {
         $field = 'attr_datetime_' . $field;
         if (is_array($value)) {
             foreach ($value as &$val) {
                 if (!is_empty_date($val)) {
                     $date = new Zend_Date($val, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
                     $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
                 }
             }
         } else {
             if (!is_empty_date($value)) {
                 $date = new Zend_Date($value, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
                 $value = $date->toString(Zend_Date::ISO_8601) . 'Z';
             }
         }
     } elseif (in_array($backendType, $this->_textFieldTypes)) {
         $field .= $languageSuffix;
     }
     if ($attribute->usesSource()) {
         $attribute->setStoreId(Mage::app()->getStore()->getId());
         foreach ($value as &$val) {
             $val = $attribute->getSource()->getOptionText($val);
         }
     }
     if (empty($value)) {
         return array();
     } else {
         return array($field => $value);
     }
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:55,代码来源:Advanced.php

示例5: _isAttributeVisible

 /**
  * Define if attribute should be visible for passed user type
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string $userType
  * @return bool
  */
 protected function _isAttributeVisible(Mage_Catalog_Model_Resource_Eav_Attribute $attribute, $userType)
 {
     $isAttributeVisible = false;
     if ($userType == Mage_Api2_Model_Auth_User_Admin::USER_TYPE) {
         $isAttributeVisible = $attribute->getIsVisible();
     } else {
         $systemAttributesForNonAdmin = array('sku', 'name', 'short_description', 'description', 'tier_price', 'meta_title', 'meta_description', 'meta_keyword');
         if ($attribute->getIsUserDefined()) {
             $isAttributeVisible = $attribute->getIsVisibleOnFront();
         } else {
             if (in_array($attribute->getAttributeCode(), $systemAttributesForNonAdmin)) {
                 $isAttributeVisible = true;
             }
         }
     }
     return (bool) $isAttributeVisible;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:24,代码来源:Product.php

示例6: addSearchParams

 /**
  * Append search params to the form
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
  * @param Varien_Data_Form                          $form      Form the
  *
  * @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
  */
 public function addSearchParams($attribute, $form)
 {
     $fieldset = $this->_getFieldset($form);
     $fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'value' => '1', 'default' => 1), 'is_searchable');
     $fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
     $fieldset->addField('is_displayed_in_autocomplete', 'select', array('name' => 'is_displayed_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Display in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
     $fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_displayed_in_autocomplete');
     $fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
     $fieldset->addField('facet_min_coverage_rate', 'text', array('name' => 'facet_min_coverage_rate', 'label' => Mage::helper('smile_elasticsearch')->__('Facet coverage rate'), 'class' => 'validate-digits validate-digits-range digits-range-0-100', 'value' => '90', 'note' => Mage::helper('smile_elasticsearch')->__('Ex: Brand facet will be displayed only if 90% of the product have a brand.')), 'is_fuzziness_enabled');
     $fieldset->addField('facets_max_size', 'text', array('name' => 'facets_max_size', 'label' => Mage::helper('smile_elasticsearch')->__('Facet max. size'), 'class' => 'validate-digits validate-greater-than-zero', 'value' => '10', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('Max number of values returned by a facet query.')))), 'facet_min_coverage_rate');
     $fieldset->addField('facets_sort_order', 'select', array('name' => 'facets_sort_order', 'label' => Mage::helper('smile_elasticsearch')->__('Facet sort order'), 'values' => array(array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_COUNT, 'label' => Mage::helper('smile_elasticsearch')->__('Result count')), array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_TERM, 'label' => Mage::helper('smile_elasticsearch')->__('Name')), array('value' => Smile_ElasticSearch_Model_Catalog_Layer_Filter_Attribute::SORT_ORDER_RELEVANCE, 'label' => Mage::helper('smile_elasticsearch')->__('Relevance')))), 'facets_max_size');
     if ($attribute->getAttributeCode() == 'name') {
         $form->getElement('is_searchable')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setValue(1);
     }
     return $this;
 }
开发者ID:diglin,项目名称:smile-magento-elasticsearch,代码行数:26,代码来源:Search.php

示例7: addSearchParams

 /**
  * Append search params to the form
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute Attribute currently edited
  * @param Varien_Data_Form                          $form      Form the
  *
  * @return Smile_ElasticSearch_Model_Adminhtml_Catalog_Product_Attribute_Edit_Form_Search
  */
 public function addSearchParams($attribute, $form)
 {
     $fieldset = $this->_getFieldset($form);
     $fieldset->addField('search_weight', 'text', array('name' => 'search_weight', 'label' => Mage::helper('smile_elasticsearch')->__('Search Weight'), 'class' => 'validate-number validate-greater-than-zero', 'value' => '1', 'default' => 1), 'is_searchable');
     $fieldset->addField('is_used_in_autocomplete', 'select', array('name' => 'is_used_in_autocomplete', 'label' => Mage::helper('smile_elasticsearch')->__('Used in autocomplete'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'search_weight');
     $fieldset->addField('is_snowball_used', 'select', array('name' => 'is_snowball_used', 'label' => Mage::helper('smile_elasticsearch')->__('Use language analysis'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_used_in_autocomplete');
     $fieldset->addField('is_fuzziness_enabled', 'select', array('name' => 'is_fuzziness_enabled', 'label' => Mage::helper('smile_elasticsearch')->__('Enable fuzziness'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()), 'is_snowball_used');
     $fieldset->addField('fuzziness_value', 'text', array('name' => 'fuzziness_value', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzziness'), 'class' => 'validate-number validate-number-range number-range-0-1', 'value' => '0.75', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 1.'), Mage::helper('smile_elasticsearch')->__('See doc at <a href="%s" target="_blank">here</a> for more information', 'http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/common-options.html#_string_fields')))), 'is_fuzziness_enabled');
     $fieldset->addField('fuzziness_prefix_length', 'text', array('name' => 'fuzziness_prefix_length', 'label' => Mage::helper('smile_elasticsearch')->__('Fuzzy prefix range'), 'class' => 'validate-digits validate-digits-range digits-range-0-9', 'value' => '2', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('A number between 0 and 9.'), Mage::helper('smile_elasticsearch')->__('Min.common prefix between original term and fuzzy matched one.')))), 'fuzziness_value');
     $fieldset->addField('facet_min_coverage_rate', 'text', array('name' => 'facet_min_coverage_rate', 'label' => Mage::helper('smile_elasticsearch')->__('Facet coverage rate'), 'class' => 'validate-digits validate-digits-range digits-range-0-100', 'value' => '90', 'note' => Mage::helper('smile_elasticsearch')->__('Ex: Brand facet will be displayed only if 90% of the product have a brand.')), 'fuzziness_prefix_length');
     $fieldset->addField('facets_max_size', 'text', array('name' => 'facets_max_size', 'label' => Mage::helper('smile_elasticsearch')->__('Facets Max Size'), 'class' => 'validate-digits validate-greater-than-zero', 'value' => '1000', 'note' => implode('</br>', array(Mage::helper('smile_elasticsearch')->__('Max number of values returned by a facet query.')))), 'facet_min_coverage_rate');
     $fieldset->addField('facets_sort_order', 'select', array('name' => 'facets_sort_order', 'label' => Mage::helper('smile_elasticsearch')->__('Facet sort order'), 'values' => array(array('value' => Smile_ElasticSearch_Model_Resource_Engine_Elasticsearch_Query_Facet_Terms::SORT_ORDER_COUNT, 'label' => Mage::helper('smile_elasticsearch')->__('By results number')), array('value' => Smile_ElasticSearch_Model_Resource_Engine_Elasticsearch_Query_Facet_Terms::SORT_ORDER_TERM, 'label' => Mage::helper('smile_elasticsearch')->__('By name')))), 'facets_max_size');
     if ($attribute->getAttributeCode() == 'name') {
         $form->getElement('is_searchable')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setDisabled(1);
         $form->getElement('is_used_in_autocomplete')->setValue(1);
     }
     return $this;
 }
开发者ID:anndream,项目名称:smile-magento-elasticsearch,代码行数:27,代码来源:Search.php

示例8: getAttributeLabel

 /**
  * Return Product Attribute Store Label
  * Set attribute name like frontend lable for custom attributes (which wasn't defined by Google)
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param int $storeId Store View Id
  * @return string Attribute Store View Label or Attribute code
  */
 public function getAttributeLabel($attribute, $storeId)
 {
     $attributeId = $attribute->getId();
     $frontendLabel = $attribute->getFrontend()->getLabel();
     if (is_array($frontendLabel)) {
         $frontendLabel = array_shift($frontendLabel);
     }
     if (!isset($this->_attributeLabels[$attributeId])) {
         $this->_attributeLabels[$attributeId] = $attribute->getStoreLabels();
     }
     if (isset($this->_attributeLabels[$attributeId][$storeId])) {
         return $this->_attributeLabels[$attributeId][$storeId];
     } else {
         if (!empty($frontendLabel)) {
             return $frontendLabel;
         } else {
             return $attribute->getAttributeCode();
         }
     }
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:28,代码来源:Product.php

示例9: _getAttributeLabel

 /**
  * Return Product Attribute Store Label
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param int $storeId Store View Id
  * @return string Attribute Store View Label or Attribute code
  */
 protected function _getAttributeLabel($attribute, $storeId)
 {
     $frontendLabel = $attribute->getFrontend()->getLabel();
     if (is_array($frontendLabel)) {
         $frontendLabel = array_shift($frontendLabel);
     }
     if (!$this->_translations) {
         $moduleName = Mage_Catalog_Model_Entity_Attribute::MODULE_NAME;
         $separator = Mage_Core_Model_Translate::SCOPE_SEPARATOR;
         $this->_translations = Mage::getModel('core/translate_string')->load($moduleName . $separator . $frontendLabel)->getStoreTranslations();
     }
     if (isset($this->_translations[$storeId])) {
         return $this->_translations[$storeId];
     } else {
         return $attribute->getAttributeCode();
     }
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:24,代码来源:Item.php

示例10: getLocaleAttributeFieldName

 /**
  * Returns attribute field name (localized if needed).
  *
  * @depreated not in use
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string                                    $locale
  * @return string
  */
 public function getLocaleAttributeFieldName(Mage_Catalog_Model_Resource_Eav_Attribute $attribute, $locale = null)
 {
     if (!$attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
         return '';
     }
     $attributeCode = $attribute->getAttributeCode();
     if ($attributeCode != 'score' && !in_array($attribute->getBackendType(), $this->_nonLocaleTypes)) {
         if (null === $locale) {
             $locale = $this->getLocaleCode();
         }
         $languageCode = $this->getLanguageCodeByLocaleCode($locale);
         $languageSuffix = $languageCode ? '_' . $languageCode : '';
         $attributeCode .= $languageSuffix;
     }
     return $attributeCode;
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:25,代码来源:Engine.php

示例11: getProductAttributeValue

 /**
  * Retrieve Product Attribute Value
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @return string
  */
 public function getProductAttributeValue($product, $attribute)
 {
     if (!$product->hasData($attribute->getAttributeCode())) {
         return Mage::helper('Mage_Catalog_Helper_Data')->__('N/A');
     }
     if ($attribute->getSourceModel() || in_array($attribute->getFrontendInput(), array('select', 'boolean', 'multiselect'))) {
         //$value = $attribute->getSource()->getOptionText($product->getData($attribute->getAttributeCode()));
         $value = $attribute->getFrontend()->getValue($product);
     } else {
         $value = $product->getData($attribute->getAttributeCode());
     }
     return (string) $value == '' ? Mage::helper('Mage_Catalog_Helper_Data')->__('No') : $value;
 }
开发者ID:relue,项目名称:magento2,代码行数:20,代码来源:List.php

示例12: getSearchEngineFieldName

 /**
  * Retrieve attribute field name
  *
  * @param   Mage_Catalog_Model_Resource_Eav_Attribute|string $attribute
  * @param   string $target - default|sort|nav
  *
  * @return  string|bool
  */
 public function getSearchEngineFieldName($attribute, $target = 'default')
 {
     $fieldName = $attribute->getAttributeCode();
     if ($fieldName == 'price') {
         return $this->getPriceFieldName();
     }
     return $fieldName;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:16,代码来源:Engine.php

示例13: array

 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  Test
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/* Create attribute */
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
$attribute = new Mage_Catalog_Model_Resource_Eav_Attribute();
$attribute->setData(array('attribute_code' => 'attribute_with_option', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, 'option' => array('value' => array('option_0' => array(0 => 'Option Label'))), 'backend_type' => 'int'));
$attribute->save();
/* Assign attribute to attribute set */
$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId());
/* Create simple products per each option */
$options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection();
$options->setAttributeFilter($attribute->getId());
foreach ($options as $option) {
    $product = new Mage_Catalog_Model_Product();
    $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Simple Product ' . $option->getId())->setSku('simple_product_' . $option->getId())->setPrice(10)->setCategoryIds(array(2))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1))->save();
    Mage::getSingleton('Mage_Catalog_Model_Product_Action')->updateAttributes(array($product->getId()), array($attribute->getAttributeCode() => $option->getId()), $product->getStoreId());
}
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:31,代码来源:attribute_with_option.php

示例14: getProductAttributeValue

 /**
  * Retrieve Product Attribute Value
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @return string
  */
 public function getProductAttributeValue($product, $attribute)
 {
     if (!$product->hasData($attribute->getAttributeCode())) {
         return '&nbsp;';
     }
     if ($attribute->getSourceModel() || in_array($attribute->getFrontendInput(), array('select', 'boolean', 'multiselect'))) {
         //$value = $attribute->getSource()->getOptionText($product->getData($attribute->getAttributeCode()));
         $value = $attribute->getFrontend()->getValue($product);
     } else {
         $value = $product->getData($attribute->getAttributeCode());
     }
     return $value ? $value : '&nbsp;';
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:20,代码来源:Product_Compare_List.php

示例15: getAttributeSolrFieldName

 /**
  * Retrieve attribute field's name for sorting
  *
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  *
  * @return string
  */
 public function getAttributeSolrFieldName($attribute)
 {
     $attributeCode = $attribute->getAttributeCode();
     if ($attributeCode == 'score') {
         return $attributeCode;
     }
     $field = $attributeCode;
     $backendType = $attribute->getBackendType();
     $frontendInput = $attribute->getFrontendInput();
     if ($frontendInput == 'multiselect') {
         $field = 'attr_multi_' . $field;
     } elseif ($frontendInput == 'select' || $frontendInput == 'boolean') {
         $field = 'attr_select_' . $field;
     } elseif ($backendType == 'decimal') {
         $field = 'attr_decimal_' . $field;
     } elseif (in_array($backendType, $this->_textFieldTypes)) {
         $locale = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
         $languageCode = $this->getLanguageCodeByLocaleCode($locale);
         $languageSuffix = $languageCode ? '_' . $languageCode : '';
         $field .= $languageSuffix;
     }
     return $field;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:30,代码来源:Data.php


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