Skip to content

Instantly share code, notes, and snippets.

@rgranadino
Created September 20, 2013 23:07
Show Gist options
  • Save rgranadino/6645104 to your computer and use it in GitHub Desktop.
Save rgranadino/6645104 to your computer and use it in GitHub Desktop.
Magento Sync Product Attributes
public function syncConfigProductAttributes(Mage_Catalog_Model_Product $product)
{
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
/* @var $productType Mage_Catalog_Model_Product_Type_Configurable */
$productType = $product->getTypeInstance(true);
$syncAttributes = array('short_description', 'description');
foreach ($productType->getUsedProductCollection($product) as $childProduct) {
//$childProduct->load($childProduct->getId());
/* @var $childProduct Mage_Catalog_Model_Product */
foreach ($syncAttributes as $attributeCode) {
$childProduct->setData($attributeCode, $product->getData($attributeCode));
}
$childProduct->save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment