While trying to load the simple product "child" of a configurable product in the order email item detail, I ran this code:
if ($_item->getProductType() == 'configurable') {
$options = $_item->getProductOptionByCode('info_buyRequest');
/** @var Mage_Catalog_Model_Product $_simpleProduct */
$_simpleProduct = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($options['super_attribute'], $_product);
} else {
/** @var Mage_Catalog_Model_Product $_simpleProduct */
$_simpleProduct &= $_product;
}
...and got this error:
PHP Fatal error: Call to a member function getBackend() on a non-object in [...]\app\code\core\Mage\Eav\Model\Entity\Abstract.php on line 816
It looks like that line tries to load an attribute, and can't find it, and then errors. The attribute code that it's trying to load is uenc
which I can't find anywhere in eav_attribute
. It turns out that uenc
is a key in the array returned by $options = $_item->getProductOptionByCode('info_buyRequest');
and I don't know why.
After some searching of the codebase, all I can find are various third party modules that all unset this array key as if it's consistently problematic, and a note about the value of this key being a base64 encoded product URL for the purchased product. (It looks like the constant PARAM_NAME_URL_ENCODED
is actually used when this data is being added.)
Does anyone know what this is here for, and why it breaks getProductByAttributes()
? It seems like I'm not the first developer to run into this issue.