magento-通过商店视图获取属性选项标签 [英] magento - get attribute option label by store view
本文介绍了magento-通过商店视图获取属性选项标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
像标题一样,如何获得特定商店视图而不是当前商店视图的属性选项值?
Like the title, how can I get the attribute option value of a specific store view instead of the current store view ?
我要实现的是这样的:
public function getAttributeOptionValue($attributeCode, $attributeOptionLabel, $storeView)
attributeOptionLabel是当前的属性选项标签.
The attributeOptionLabel is the current attribute option label.
推荐答案
简单!引用 Mage_Eav_Model_Entity_Attribute::getStoreLabel()
[link] :
Simple! Ref Mage_Eav_Model_Entity_Attribute::getStoreLabel()
[link]:
<?php
include 'app/Mage.php';
Mage::app('default');
//Generic access
$eavConfig = Mage::getSingleton('eav/config');
/* @var $eavConfig Mage_Eav_Model_Config */
$eavAttribute = $eavConfig->getAttribute(
Mage_Catalog_Model_Product::ENTITY, // 'catalog_product'; see db.eav_entity_type
'description' // attribute code
);
/* @var $eavAttribute Mage_Eav_Model_Entity_Attribute */
Zend_Debug::dump(
$eavAttribute->getStoreLabel('admin')
);
//For a given EAV entity-based model, the resource requires only the attribute
$product = Mage::getModel('catalog/product')->load(2);
/* @var $product Mage_Catalog_Model_Product */
$productAttribute = $product->getResource()->getAttribute('description');
/* @var $productAttribute Mage_Eav_Model_Entity_Attribute */
Zend_Debug::dump(
$productAttribute->getStoreLabel('admin')
);
//It's also possible to get all labels:
Zend_Debug::dump(
$productAttribute->getStoreLabels()
);
这篇关于magento-通过商店视图获取属性选项标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文