Created
September 20, 2013 23:07
-
-
Save rgranadino/6645104 to your computer and use it in GitHub Desktop.
Magento Sync Product Attributes
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
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