Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Overwriting Product Attribute
 
NELAGeek
Sr. Member
 
Avatar
Total Posts:  193
Joined:  2010-01-23
US
 

I have a custom attribute.  I would like to overwrite a core attribute’s value with the value of my custom attribute immediately after the product object is built, so that any code that calls the core attribute’s value will receive the value of my custom attribute.

Any ideas guys?

** bump **

No help on this one?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Indies Inc
Sr. Member
 
Avatar
Total Posts:  193
Joined:  2013-09-18
 

Hi,
At any time you can set the value of product attribute after creating that product. So you can just create the module and observer that is called when product is created and you will just have to set the value of different attributes of that product and save that product. See the following code that I am using.

Example:

$product = new Mage_Catalog_Model_Product(); 
            
$product->setTypeId('virtual');
            
$product->setAttributeSetId(9);
            
$product->setName($_POST['companyname']);
            
$product->setSku($_POST['companyurl']);
            
$product->setStatus(1); 
            
$product->setTaxClassId(0);
            
$product->setUrlKey($newurl); 
            
$product->setVisibility(4);
            
$product->setPrice("1.00");
            
$product->save();

Hope this will be helpful to you.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top