# How to load and save product in EE 1.13

In previous versions of Magento, I was able to use this code:

$product = Mage::getModel('catalog/product')->load(147);$product->setDescription('test description');
$product->save();  However, in EE 1.13.1, I am getting a fatal error: Fatal error: Uncaught exception 'Mage_Eav_Model_Entity_Attribute_Exception' with message 'Product with the 'louis-vuitton-handbag' url_key attribute already exists.' in /Applications/XAMPP/xamppfiles/htdocs/magentoee113/app/code/core/Mage/Core/Model/Config.php:1348 .... If I set the store ID when loading the product, then it works: $product = Mage::getModel('catalog/product')->setStoreId(0)->load(147);
$product->setDescription('test description');$product->save();


What is the proper way to do this?

Thanks.

To save prices per website/store and to avoid getting the 'url_key' error do the following:

foreach ($storeIds as$storeId) {
//load the product with store id
$product = Mage::getModel('catalog/product') ->setStoreId($storeId)
->load($productId); //Set the store price$product->setPrice($price); //To stop Magento regenerating url-key for store, set following,$product->setUrlKey(false);

//Save the product
\$product->save();
}


This has been tested and it works.

• Wow, there is no way I would know to use setURLKey(false). – dnelson Jun 13 '14 at 1:38

(Possible Assumption) Adding the setStoreId appears to be required now in 1.13.1.0

• I think you are wrong. You have to set the store_id if you want to save or load storeview specific content. If you want to get website scoped content or default, then you don't need this. – Fabian Blechschmidt Mar 11 '14 at 22:37
• magento.stackexchange.com/questions/12500/… This problem, leads me to believe my assumption. – Aepod Mar 11 '14 at 23:59
• Interesting magento bug - I think. Thanks for the link. The problem is, magento tries to save everything in store view scope (because you are in frontend?) but the url_key already exists and magento doesn't realize it is the same product? whatever. If it solves the problem I'll be quiet. – Fabian Blechschmidt Mar 12 '14 at 7:18

There is official magento patch to fix that. This is a bug.