1

I spent all of yesterday trying to get to the bottom of this error that appears every time you access a product page on our Magento store (CE edition 1.9.0.1):

2015-07-24T12:20:09+00:00 ERR (3): Notice: Array to string conversion in /[Path to Magento]/app/code/core/Mage/Catalog/Block/Product/View/Attributes.php on line 66

It's this block of code in the attributes.php file:

if (!$product->hasData($attribute->getAttributeCode())) {
    $value = Mage::helper('catalog')->__('N/A');
} elseif ((string)$value == '') {
    $value = Mage::helper('catalog')->__('No');
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
    $value = Mage::app()->getStore()->convertPrice($value, true);
}

specifically this:

} elseif ((string)$value == '') {
  • I've googled the issue and can't find it anywhere else.
  • I assumed it's something to do with product attributes so I deleted all of the custom product attributes we'd created one by one.
  • I disabled all extensions one by one.
  • I reverted the design templates back to the default Magento ones.

And still the error kept popping up...

I'm pretty much a novice when it comes to all of this stuff, so my trial and error fixes haven't helped me out... Has anyone got any ideas or can point me in the direction of how to troubleshoot this error a little more?

2

Pretty simple: You're trying to cast $value as a string for the comparison, but $value is an array. If $value has some kind of value you need in it (perhaps it's nested inside an array) for the comparison, then you must process it so that it is not array.

Do this before the if statement.

var_dump($value); die;

Or

Mage::log($value); // Check var/log/system.log with logging enabled

And just examine how the data is structured in $value. Make it into a string variable.

| improve this answer | |
  • 1
    Thank you! This helped me figure out it was the tier_price attribute causing the issue. Setting Visible on Product View Page on Front-end to No for the tier-price attribute stopped the array error. – PoorLummox Jul 24 '15 at 15:39
0
  1. turn off DeveloperMode to not get this notice
  2. temporary Edit the Core File (Block/Product/View/Attributes.php) by:

    if (is_array($value)) {
        var_dump($attribute->getAttributeCode(), $value);
    }
    

    below $value = $attribute->getFrontend()->getValue($product);

  3. Refresh the Product Page to see which Attribute is invalid and

  4. exclude the attribute in your call (probably in your Template) like

    $_additional = $this->getAdditionalData(array('attribute_code')
    
| improve this answer | |

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.