所以我有
$attribute_option_id = Mage::getResourceModel('catalog/product')
->getAttributeRawValue($productId, 'my_attribute', $storeId);
这给了我类似$attribute_option_id = 12345
的东西
现在,我如何获取此id的(文本)值?
感谢
这应该可以工作。
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
$text = $product->getAttributeText('my_attribute');
[EDIT]
如果你不想加载完整的产品,你可以偷偷地想一想。模仿产品。
所以你得到了选项id,就像你已经做一样
$attribute_option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'my_attribute', $storeId);
然后只创建一个空的产品实例,并为其设置一些属性
$product = Mage::getModel('catalog/product')
->setStoreId($storeId)
->setData('my_attribute', $attribute_option_id);//the result from above
$text = $product->getAttributeText('my_attribute');
已经有人证实这是有效的。请在此处查看。
这里有一个对我有用的不同方法
假设已知:$_current_product-
$_Current_OptionId = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_current_productid, $attribute_id,$store_id);
$_write = Mage::getSingleton('core/resource')->getConnection('core_write');
// now $_write is an instance of Zend_Db_Adapter_Abstract
$_readresult=$_write->query("SELECT value FROM eav_attribute_option_value WHERE option_id ='".$_Current_OptionId."'");
while ($row = $_readresult->fetch() ) {$_Current_OptionValue=$row['value'];}