Magento创建新的产品模板


Magento create new product template

我真的很喜欢magento的结构,但找到东西非常困难;)

我的问题是我有一个自定义属性。通过调用"创建新产品",此字段应预先填充一个自动值,如实体 ID。这应该只发生在创建新函数中。

我绝对无法找到相应的代码,在哪里设置了初始值,谁能给我一个提示?(必须运行脚本,而不是默认值:))

非常感谢和勤奋,马蒂亚斯

您可以在这篇文章中找到查找相应代码所需的信息:在Magento中查找正确的模板和块

只需将字段的默认属性更改为所需的属性即可。

我的问题的答案是覆盖Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes块。

在此块中,您可以使用简单的 if 条件。 以下行必须替换为 if:

$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();

新解决方案:

if($attribute->getAttributeCode() == 'my_attribute_code') {
    $values[$attribute->getAttributeCode()] = SET_THE_OWN_VALUE;
} else {
    $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}

仅此而已:)

希望这对其他人也有帮助!!