本文整理汇总了PHP中Mage_Catalog_Model_Resource_Eav_Attribute::getFrontend方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Eav_Attribute::getFrontend方法的具体用法?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getFrontend怎么用?PHP Mage_Catalog_Model_Resource_Eav_Attribute::getFrontend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Resource_Eav_Attribute
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Resource_Eav_Attribute::getFrontend方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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();
}
}
}
示例3: _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();
}
}
示例4: 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;
}
示例5: 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 ' ';
}
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 : ' ';
}
示例6: getValueOrValueText
protected function getValueOrValueText(Mage_Catalog_Model_Product $product, $name, Mage_Catalog_Model_Resource_Eav_Attribute $resource)
{
$value_text = $product->getAttributeText($name);
if (!$value_text) {
$value_text = $resource->getFrontend()->getValue($product);
}
return $value_text;
}