-
-
Save amacgregor/1134597 to your computer and use it in GitHub Desktop.
Child sku
This file contains hidden or 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
<?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> |
This file contains hidden or 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
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<Demac_Childsku> | |
<active>true</active> | |
<codePool>local</codePool> | |
</Demac_Childsku> | |
</modules> | |
</config> |
This file contains hidden or 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
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