- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017
11:09 PM
07-25-2017
11:09 PM
Hello. I am Marvin. Anyone here can help how to create Magento attributes using Magento Extension. Here is the instruction:
- I have to create a new Yes/No attribute for products. The code should be display_product.
- The code should be able to install in Magento extension because I will use git and host the code in github. I am using Magento CE 1.9 Thanks.
I am Marvin
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017
02:39 PM
07-26-2017
02:39 PM
Thanks. I also tried Silk Software website easily generate files on creating attributes.
I am Marvin
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017
10:57 AM
07-26-2017
10:57 AM
Re: Creating Magento attributes using Magento Extension
Hi @Marvin261,
You can create an installer script, with something like this:
$installer = $this; $installer->startSetup(); $attribute_set_id = $installer->getDefaultAttributeSetId(Mage_Catalog_Model_Product::ENTITY); $attribute_group_id = $installer->getAttributeGroupId(Mage_Catalog_Model_Product::ENTITY, $attribute_set_id, 'General'); $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'display_product', array( 'type' => 'int', 'frontend' => '', 'label' => 'Display product', 'input' => 'select', 'backend' => '', 'class' => '', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'default' => '', 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 1, 'unique' => 0, 'position' => 15, )); $installer->addAttributeToGroup( Mage_Catalog_Model_Product::ENTITY, $attribute_set_id, $attribute_group_id, 'display_product', '15' ); $installer->endSetup();
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2017
02:39 PM