Magento Attribute Error – Image File Not Found Exception

attributeserror

I created an attribute called “Size” and added Small, Medium, and Large. I gave 3 existing simple products (which are attached to a configurable) a different size so I could see the new option in a dropdown on the details page. But when I loaded the details page, an error came up. Here is the log message:

2014-05-29T20:05:31+00:00 ERR (3): 
exception 'Exception' with message 'Image file was not found.' in /home/pivotal/public_html/app/code/core/Mage/Catalog/Model/Product/Image.php:308
Stack trace:
#0 /home/pivotal/public_html/app/code/core/Mage/Catalog/Helper/Image.php(163): Mage_Catalog_Model_Product_Image->setBaseFile(NULL)
#1 /home/pivotal/public_html/app/design/frontend/default/pivotal/template/catalog/product/view.phtml(151): Mage_Catalog_Helper_Image->init(Object(Mage_Catalog_Model_Product), 'color_swatch')
#2 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/pivotal/p...')
#3 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#4 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#5 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#6 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#7 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#8 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#9 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#10 /home/pivotal/public_html/app/design/frontend/default/pivotal/template/page/1column.phtml(48): Mage_Core_Block_Abstract->getChildHtml('content')
#11 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/pivotal/p...')
#12 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#13 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#14 /home/pivotal/public_html/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Template->_toHtml()
#15 /home/pivotal/public_html/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#16 /home/pivotal/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#17 /home/pivotal/public_html/app/code/core/Mage/Catalog/Helper/Product/View.php(147): Mage_Core_Controller_Varien_Action->renderLayout()
#18 /home/pivotal/public_html/app/code/core/Mage/Catalog/controllers/ProductController.php(132): Mage_Catalog_Helper_Product_View->prepareAndRender(2, Object(Mage_Catalog_ProductController), Object(Varien_Object))
#19 /home/pivotal/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Catalog_ProductController->viewAction()
#20 /home/pivotal/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#21 /home/pivotal/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#22 /home/pivotal/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#23 /home/pivotal/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#24 /home/pivotal/public_html/index.php(87): Mage::run('', 'store')
#25 {main}

Line 151 of view.phtml is:

$swa_file = $this->helper('catalog/image')->init($swatch, 'color_swatch')->keepFrame(false)->resize(40);

After trying and undoing a few different things, I went ahead and tried deleting the new Size attribute. The error is still there 🙁

I tried:

  • Adding size.jpg and rollover_image.jpg to /skin/frontend/default/[theme]/images/catalog/product/placeholder
  • Verifying that placeholder images have been uploaded in the configuration
  • Adding images to each of the simple products (before only the configurable had images)

Any ideas are greatly appreciated.

Best Answer

On Line 151 of view.phtml change 'color_swatch' back to 'image' and $swatch back to $product.

$swa_file = $this->helper('catalog/image')->init($product, 'image')->keepFrame(false)->resize(40);

I'm assuming $swatch and color_swatch are supposed to be a custom image related to an extension. For some reason Magento cannot find it, causing the issue.

You can see at the very top of your stack trace it's setting the baseFile to NULL which is the cause of the issue.

Mage_Catalog_Model_Product_Image->setBaseFile(NULL)