I want to copy a product's attribute (weight) to another atribute (general_weight).
I found this:
Create an script at magento root update.php
and put the below code :
<?php
require_once "app/Mage.php";
Mage::app("admin");
umask();
/*
Step2: get Product Collection filter by Saleable
*/
$collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('weight');
foreach($collection as $eachproduct){
$val=$product->getWeight();
/*$product->getWeight() is not given the value then used
$product->getResource()->getAttribute('weight')->getFrontend()->getValue($product-)
*/
$product->setGeneralWeight($val);
$product->getResource()->saveAttribute($product, 'general_weight');
}
then run the script by browser or shell php program.
but this faces to an error:
Fatal error: Call to a member function getWeight() on a non-object in update.php on line 12