一个非常小的事情让我疯狂:)
我无法检索/catalog/product/view/type/options/configurable.phtml模板文件中当前属性的属性代码.
当我改变时,在第36行(或在第36行)
echo $_attribute->getLabel()
Run Code Online (Sandbox Code Playgroud)
至
echo $_attribute->getAttributeId()
Run Code Online (Sandbox Code Playgroud)
我得到eav_attribute了数据库表中存在的正确属性Id .但是,当我尝试
echo $_attribute->getAttributeCode()
Run Code Online (Sandbox Code Playgroud)
我得到一个空字符串,而表中有一个attribute_code字段eav_attribute.
你能帮我找一下属性的属性代码吗?或者,更一般地说:如何获取我们现在为id的属性的属性代码?
非常感谢!
小智 16
在这种情况下,无需重载Magento基本代码.如果你print_r($ _ attribute)你可以看到属性代码在array()中更深,你可以这样直接在你的模板文件中使用它:
echo $_attribute->getProductAttribute()->getAttributeCode();
Run Code Online (Sandbox Code Playgroud)