Magento's getAttributeText is inconsistent

I’m trying to write some custom logic for browsing and searching in a Magento store.

So I figured I’d overwrite getProductCollection for both Mage_Catalog_Model_Layer and Mage_CatalogSearch_Model_Layer.

I’m trying to make decisions based on what the value of certain Attributes are for some of the products in the collection, but I can’t seem to get the text value of all attributes.

The function as I’ve overwritten is:

public function getProductCollection()
    if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
        $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
    } else {
        $collection = $this->getCurrentCategory()->getProductCollection();
        $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;

    foreach($collection as $product) {
            echo "nSKU: ".$product->getSku()."n";
            $product_data = $product->getData();
            if(isset($product_data['parent_sku']) && ($product_data['parent_sku'] != '')) {
                    echo "GETDATA PARENT: ".$product_data['parent_sku']."n";
            if($product->getAttributeText('parent_sku') != '') {
                    echo "ATTR TEXT PARENT: ".$product->getAttributeText('parent_sku')."n";
            if($product->getAttributeText('door_color') != '') {
                    echo "ATTR TEXT COLOR: ".$product->getAttributeText('door_color')."n";
    //end ben

    return $collection;

This produces output like:


I add both ‘parent_sku’ and ‘door_color’ as attributes to select.
I can access door_color using $product->getAttributeText()
I cannot access parent_sku using $product->getAttributeText()
I can access parent_sku through $product->getData()

Any time I call $product->getAttributeText(‘parent_sku’) it returns false.

I assumed that this was a caching problem, but I flushed the cache and that didn’t seem to help.

Does anyone have a clue why I can’t access the value of ‘parent_sku’ through getAttributeText()?

One thought on “Magento's getAttributeText is inconsistent”

  1. Is parent_sku implemented as a dropdown box? My understanding is that getAttributeText loaded dropdown options and mapped them from and ID to text for you.

Leave a Reply

Your email address will not be published. Required fields are marked *