views:

2806

answers:

2

Hi there,

I have added some custom attributes to the products in the admin section of our Magento 1.3.2.1 installation and I've given some of those attributes default values. The problem is that the default values aren't being returned when I try to get the attribute from the product object as follows:

$_product->getCode()

Logically, I would imagine that the default value gets returned if there isn't one stored against the product, but this doesn't seem to be the case (unless I'm plainly missing something).

The list below is all the current settings for one of the attributes that isn't returning the default value set.

Attribute Properties:

Attribute Code: code

Scope: Store View

Catalog Input Type for Store Owner: Text Field

Default value: value

Unique Value: No

Values Required: No

Input Validation for Store Owner: None

Apply To: All Product Types

Frontend Properties:

Use in quick search: No

Use in advanced search: No

Comparable on Front-end: No

Use In Layered Navigation: No

Use In Search Results Layered Navigation: No

Use for Price Rule Conditions: No

Position: 0

Allow HTML-tags on Front-end: Yes

Visible on Product View Page on Front-end: Yes

Used in product listing: Yes

Used for sorting in product listing: No

Thanks for your help! Remy

A: 

Hi Remy

I have the same problem. Could you figure out a fix for this?

Thanks mollo

mollocampo
Hi Mollo.As far as I could figure out, the default value is used when you create a new product. In other words, when you create a new product, it gets all the default values as opposed to the default values being used when there isn't one on existing products.Hope this helps you.Kind Regards,Remy
Remy
A: 

It seams that the Mage_Core_Model_Abstract class will not check for attributes in the __get magic method. Try using the getData method instead:

$_product->getData('code');
MANCHUCK