将产品属性移到magento admin中的新组 [英] Move a product attribute to a new group in magento admin
本文介绍了将产品属性移到magento admin中的新组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我像这样创建了一个属性...
I created an attribute like so...
$installer = $this;
$installer->startSetup();
/* $installer Services_Issue_Model_Mysql4_Setup */
$installer->addAttribute('catalog_product', 'alice_id', array(
'backend' => '',
'frontend' => '',
'type' => 'text',
'visible' => true,
'label' => 'Alice Id',
'note' => 'Alice Id.',
'input' => 'text',
'unique' => true,
'source' => '',
'global' => true,
'visible' => true,
'required' => true,
'user_defined' => true,
'default' => '',
'visible_on_front' => true,
'apply_to' => 'simple,configurable,default',
'group' => 'Special Attributes',
'used_in_product_listing' => true,
'frontend_class' => '',
'class' => '',
'is_html_allowed_on_front' => true,
'searchable' => true
));
$installer->endSetup();
现在,我需要将其移动到产品信息页面内的另一个组.因此,我尝试了此尝试,但没有成功.
Now I need to move it to another group within the product information page. So I've tried this without any success.
$installer = $this;
$installer->startSetup();
/* $installer Services_Issue_Model_Mysql4_Setup */
$installer->updateAttribute('catalog_product', 'alice_id', 'note', 'Product SKU for Alice.com third-party cart & checkout.');
/* - move between groups not possible with updateAttribute - */
$installer->updateAttribute('catalog_product', 'alice_id', 'group', 'Additional Attributes');
$installer->endSetup();
谁能告诉我我该如何做到这一点?
Can anyone tell me how I can accomplish this?
推荐答案
您可以在Mage_Eav_Model_Entity_Setup
中使用addAttributeToGroup($entityType, $attributeSetId, $attributeGroupId, $attributeId, $sortOrder)
方法将属性移至其他组.首先,您需要获取设置ID和组ID.
You can use the addAttributeToGroup($entityType, $attributeSetId, $attributeGroupId, $attributeId, $sortOrder)
method in Mage_Eav_Model_Entity_Setup
to move an attribute to a different group. First, you'll need to get the set ID and group ID.
// ... start setup
// get default set id
$setId = $installer->getDefaultAttributeSetId('catalog_product');
// get group id by name "Additional Attributes"
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_group_collection');
foreach ($attributeSetCollection->getData() as $attributeGroupIndex) {
foreach ($attributeGroupIndex as $key => $value) {
if ($key === "attribute_group_name" and $value === "Additional Attributes") {
$groupId = $attributeGroupIndex["attribute_group_id"];
break 2;
}
}
}
// move attribute 'alice_id' to group 'Additional Attributes'
if (isset($setId) and isset($groupId)) {
$installer->addAttributeToGroup('catalog_product', $setId, $groupId, 'alice_id', 1000);
}
// ... end setup
这篇关于将产品属性移到magento admin中的新组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文