Magento – Can’t get custom attribute from getUsedProducts

collection;product-attribute

This follows on from my previous question.

I am getting all the child products of it's parents by using the following:-

$associatedProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);

I am already fetching values from custom attributes (dropdowns) in simple products using the following:-

$sizing = $simple->getAttributeText('product_size_women');

This works fine, I am able to get the size value for each simple product but this attribute is set as 'Use To Create Configurable Product'.

I cannot fetch the values from a different custom attribute (also a dropdown) that isn't used to create a configurable product though and I suspect this has something to do with how getUsedProducts functions.

I have tried loading the attribute id into an array like below but this has no affect probably because attributes that aren't used to create a configurable cannot be retrieved in this function – I'm unsure.

getUsedProducts(array(id_of_your_attribute), $product)

I'd simply like to get the value of the custom attribute in the same way as I am getting the sizing ones above:-

$sendtofeed = $simple->getAttributeText('attribute_code'));

Can someone point out where I am going wrong?

Best Answer

Don't know if it's a hack or the normal way, but you can get the attribute id using

$sizeId = $simple->getResource()->getAttributeRawValue($simple->getId(), 'product_size_women', 0);

and the text using

$simple->getResource()->getAttribute('product_size_women')->getSource()->getOptionText($sizeId)
Related Topic