0

In a little generic exporter I am currently writing I am exporting all products and their attributes that reside in the data array.

For some attributes, it is necessary to translate their integer value into their frontend value (manufacturer, brand ...).

The best way I found to do that so far is this:

$storeviewProduct->getResource()->getAttribute($key)->getFrontend()->getInputType()

However, for all attributes that do not have a frontend value, a FATAL ERROR is thrown:

Call to a member function getSource() on boolean in app/code/core/Mage/Catalog/Model/Product.php on line 1385

It seems that this happens whenever I try to check if this attribute has a frontend value to display. However, I cannot seem to determine if I have to check any frontend value without the FATAL ERROR.

I'd prefer not to tinker with the error settings of my script or install a custom FATAL ERROR handler to catch just this error. I hope that there's a way without iterating over all attributes first, then reading the values for the attribute from the product instead of just iterating over the data array.

0

Don't know if this questions is still relevant. But this worked for me:

$key = '...' // Key definition

$attr = $storeviewProduct->getResource()->getAttribute($key);

$value = $attr->getFrontend()->getValue($storeviewProduct);

if($storeviewProduct->getData($key)) {
  // Output
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.