Skip to content

Instantly share code, notes, and snippets.

@rgranadino
Last active August 29, 2015 14:10
Show Gist options
  • Save rgranadino/881d57aee79960651f37 to your computer and use it in GitHub Desktop.
Save rgranadino/881d57aee79960651f37 to your computer and use it in GitHub Desktop.
<?php
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'SOME SKU');
$attributes = $product->getTypeInstance(true)->getSetAttributes($product);
/* @var $mediaGalleryAttribute Mage_Catalog_Model_Resource_Eav_Attribute */
$mediaGalleryAttribute = $attributes['media_gallery'];
//FILL IN $path somehow
$mediaGalleryAttribute->getBackend()->addImage($product, $path, null, false, false);
$product->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment