没有获得属性的价值(Magento)

时间:2013-09-09 08:33:53

标签: magento magento-1.7 magento-1.4 magento-1.5 magento-1.6

我为每个产品创建了一个名为'specialtext'的属性。但是没有在frontend.Any想法中获得这个specialtext字段的值?

3 个答案:

答案 0 :(得分:1)

获取PLAIN TEXT,TEXTAREA或DATE类型属性的属性值:

$attribute_value = $product->getShirtSize(); //for shirt_size attribute

从SELECT,MULTISELECT,DROPDOWN或YES / NO属性中获取值:

$attribute_value = $product->getAttributeText($attribute_code);

答案 1 :(得分:0)

text或textarea字段

对于这些属性,请使用:

// specify the attribute code
$attributeCode = 'name';

// build and filter the product collection
$products = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToFilter($attributeCode, array('notnull' => true))
        ->addAttributeToFilter($attributeCode, array('neq' => ''))
        ->addAttributeToSelect($attributeCode);

// get all distinct attribute values
$usedAttributeValues = array_unique($products->getColumnValues($attributeCode));

希望这对您有所帮助。

答案 2 :(得分:0)

要显示新创建的产品属性,您需要将其添加到“属性集”中。 您是否已将此属性添加到属性集?