Last active
December 16, 2015 04:19
-
-
Save gabidavila/5376289 to your computer and use it in GitHub Desktop.
Alterar valor de atributo para todos os produtos no Magento
Change attribute value for all products in Magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//get all products | |
$products = Mage::getResourceModel('catalog/product_collection')->getAllIds(); | |
//Now create an array of attribute_code => values | |
$attributesData = array( | |
array('orig' => 1), | |
array('ncm' => 33030020), | |
array('ucom' => 'un'), | |
array('subst' => 1) | |
); | |
//Set the store to affect. I used admin to change all default values | |
$storeId = 0; //A.K.A Admin | |
//Now Update the attribute(s) for the given products. | |
foreach ($attributesData as $attributeData) { | |
Mage::getSingleton('catalog/product_action')->updateAttributes($products, $attributeData, $storeId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment