There are many problems when you’re working with configurable products. One of annoying issue was we forgot to make associated simple products inherit parent product categories. And of course, It will take us a lot of time to accomplish it manually. Therefore, I wrote scripts for this task. You can flow these below steps to make it done with a little time.

1/ You just needed create a new file script.php on the same index.php directory of your website.


$collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*');

foreach ($collection as $product){
if( $product->getTypeId() == "configurable"){
//var_dump($product->getCategoryIds()) ;
//echo "<br>";

$childProducts = Mage::getModel('catalog/product_type_configurable')
//$i = 1;
//$productName = $product->getId(). " - ".$product->getName();
foreach($childProducts as $child){
$arrCats = $product->getCategoryIds();
$modelProduct = Mage::getModel('catalog/product')->load($child->getId());
//echo "<br>"."\t".$i++. " - ";
//echo "Child ". $child->getId().$child->getName() ."<br>";
//echo "<br> --------------------------------------------------------------------------------------------------------------<br> ";

echo "Complete";



2/ Run this script by enter the url : http://yourwebsite/script.php

Is it easy ? Hope it can help other guys.
Enjoy coding !