繁体   English   中英

未获取属性值(Magento)

[英]Not getting value of attribute(Magento)

我为每个产品都创建了一个名为'specialtext'的属性,但是没有在前端获得此特殊文本字段的值。

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

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

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

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

文本或文本区域

对于这些属性,请使用以下命令:

// 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));

希望对您有所帮助。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM