CommercePeer Brand Logo


Programmatically: Magento 2 Product Entity

Programmatically: How to create custom Magento attribute options

To create custom Magento attribute options programmatically, you can use the Mage_Eav_Model_Entity_Attribute_Api class. Here's an example code snippet that demonstrates how to create a custom attribute option:

Create a custom attribute option


		require_once Mage::getModuleDir('models', 'Mage_Eav').DS.'Model'.DS.'Entity'.DS.'Attribute'.DS.'Api.php';

	$attributeOption = new Mage_Eav_Model_Entity_Attribute_Api();
	$attributeOption->createOption('my_attribute', 'My Option Value', 'My Option Text');
	

LET’S WORK TOGETHER

We love working with Small Businesses, Retailers, Manufacturers. Our team is here to Help.

→ Schedule Free Consultant Now
Copyright © 2024 CommercePeer. All Rights Reserved.