一个很小的事情让我发疯了:)
我无法在/catalog/product/view/type/options/configurable.phtml
模板文件中检索当前属性的属性代码。
当我更改第36行(或周围)时,
echo $_attribute->getLabel()
至
echo $_attribute->getAttributeId()
我得到了数据库的
eav_attribute
表中存在的正确属性ID。但是当我尝试
echo $_attribute->getAttributeCode()
我得到一个空字符串,而
attribute_code
表中有一个eav_attribute
字段。您能帮我找到我的属性的属性代码吗?或者,更笼统地说:如何获取我们现在从中获得ID的属性的属性代码?
非常感谢!
最佳答案
在这种情况下,无需重载Magento基本代码。
如果您使用print_r($ _ attribute),则可以看到属性代码在array()中更深,您可以通过以下方式直接在模板文件中使用它:
echo $_attribute->getProductAttribute()->getAttributeCode();
关于magento - 检索属性代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3341691/