所以我有
$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');
[编辑]
如果你不想加载完整的产品,你可以偷偷摸摸地想一想。冒充产品。
因此您可以像以前一样获得选项 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');
已经确认这有效。 See it here .
关于php - Magento 如何通过选项 ID 获取属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22987787/