I'm trying to extend Magento to where, when I update a custom attribute for a configurable product, it saves it to the corresponding custom attribute for all of its associated products. I've got an observer that watches the catalog_product_save_after event but I'm not exactly sure where to proceed in order to get it to save it to the associated products. I've looked at a lot of solutions here and other sites that deal with programmatically creating a configurable product and it's assocaited products, but nothing that does what I need. Any help would be greatly appreciated.
EDIT: Here's the final code I ended up with:
public function copyAttribute($observer) {
try {
// get the event product
$product = $observer->getEvent()->getProduct();
// check to see if product is configurable
if ($product->getData('type_id') === 'configurable') {
// get associated products
$associated = $product->getTypeInstance(true)->getUsedProducts(null, $product);
// create attribute array
$feedArray = array('feedprice1', 'feedprice2', 'feedprice3');
// loop through associated products and save configurable products changed value
foreach ($associated as $associate) {
foreach ($feedArray as $feed) {
$associate->setData($feed, $product->getData($feed));
$associate->getResource()->saveAttribute($associate, $feed);
}
}
}
}
// log any errors
catch (Exception $e) {
Mage::log(print_r($e->getMessage(), 1), 'null', 'product-attribute-update.log');
}
}
Best Answer
Create an event product save after only for configurable product save from admin.
Then using observer update
field of child products
:i haveupdate here meta description of child products using parent products meta description
Code is HereLet me know,if you have any issue
As your requested Just add below code
EDIT: