Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Forked from reztierk/Demac_Childsku
Created August 9, 2011 17:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amacgregor/1134597 to your computer and use it in GitHub Desktop.
Child sku
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Demac_Childsku>
<version>0.0.1</version>
</Demac_Childsku>
</modules>
<global>
<models>
<childsku><class>Demac_Childsku_Model</class></childsku>
</models>
</global>
<crontab>
<jobs>
<demac_childsku_add>
<schedule><cron_expr>1 1 * * *</cron_expr></schedule>
<run><model>childsku/observer::addChildSkus</model></run>
</demac_childsku_add>
</jobs>
</crontab>
</config>
<?xml version="1.0"?>
<config>
<modules>
<Demac_Childsku>
<active>true</active>
<codePool>local</codePool>
</Demac_Childsku>
</modules>
</config>
class Demac_Childsku_Model_Observer
{
public function addChildSkus()
{
$productConfig = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('type_id', 'configurable');
foreach ($productConfig as $parent){
$singleConfig = Mage::getModel('catalog/product_type_configurable')->setProduct($parent);
$simpleCollection = $singleConfig->getUsedProductCollection()->addAttributeToSelect('*');
foreach($simpleCollection as $simple){
//Do something here to modify your parent product.
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment