我有一个非常奇怪的问题,我可以在本地获取产品属性值,但是当我转到实时服务器时,我得到一个空值。马真托版本1.6.2。
要获取属性值,我使用以下代码:
$product = Mage::getModel('catalog/product')->load($_item->getProductId());
$my_attribute = $product->getAttributeText('my_attribute');
PHP 5.3 和 apache 2.2 在本地和实时服务器上
试试这些事情:
$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);
$text = $product->getAttributeText('my_attribute');
或
$_id = $this->getProduct()->getId();
$_resource = Mage::getSingleton('catalog/product')->getResource();
$optionValue = $_resource->getAttributeRawValue($_id, [ATTRIBUTE_ID/ATTRIBUTE_CODE], Mage::app()->getStore());
echo $optionValue;
或
$attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product);
干杯:-)