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

I can’t set custom attribute if the attribute code has an Integer
 
JJLaird
Jr. Member
 
Total Posts:  11
Joined:  2011-08-09
 

Hello,

I currently have an observer function set up for event catalog_product_save_before and it is working fine however I wish to set a custom attribute before the save. I can achieve this when the attribute code has no numbers in it as below however if there are numbers in the attribute code I cannot. Please can someone help me as to how I set this custom attribute if the attribute code has numbers in it.

$event = $observer->getEvent();
$product = $event->getProduct();
$sku = $product->getEntityId();

$product->setTesting(’88’) //This works for attribute code ‘testing’
$product->setShippingPrice35(’88’) //This doesn’t work for attribute code ‘shipping_price_3_5’ ????

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

The correct way for attribute names with numbers in the name is:

$product->setShippingPrice_3_5('88');

or you can use the alternative way:

$product->setData('shipping_price_3_5''88');
 
Magento Community Magento Community
Magento Community
Magento Community
 
JJLaird
Jr. Member
 
Total Posts:  11
Joined:  2011-08-09
 

Thank you that’s great!!

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