I have this code:

foreach ($skuScope as $sku)
    $object = Mage::getModel('catalog/product');
    $product = $object->loadByAttribute('sku', $sku);

    $attributes = $product->getAttributes();
    foreach ($attributes as $attribute) {
        $attributeCode = $attribute->getAttributeCode();
        $value = $attribute->getFrontend()->getValue($product);

I can get all attributes, all values, but I don’t know how to rewrite values for an attribute

Help me, please! Thanks!

1 Answer 1


Please do like this.



$productCollection = Mage::getModel('catalog/product')->getCollection();

foreach($productCollection as $product) 
    $attributeCode = "my_option";
    echo "\n".'updating '.$product->getSku()."...\n";
    $product = Mage::getModel('catalog/product’)
    $product->setData($attributeCode, "enter_your_value")
            ->saveAttribute($product, $attributeCode);

Happy Coding :)

  • This does not fit, I need to rewrite the value of an existing attribute Apr 6, 2020 at 14:32
  • Yes this is just a example of the code. Apr 6, 2020 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.