My store have around 20000 products and now i want to generate google feed with simple products but associated products don't have images, only configurable products have images. Now what i want is to associated configurable product image to its all associated product so when i generate feed associated products takes the image of its main configurable product.
I have try this by create a module but
<?php
class Ebiz_Assignimage_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction()
{
$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', array('eq' => 'configurable'));
// echo '<pre>'; print_r($collectionConfigurable->getData()); die;
foreach ($collectionConfigurable as $_configurableproduct) {
$product = Mage::getModel('catalog/product')->load($_configurableproduct->getId());
if($product->isSaleable()) {
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
foreach($childIds[0] as $key=>$val) {
$associatedProduct = Mage::getModel('catalog/product') ->load($val);
$associatedProduct->setImage($product->getImage())
->save();
//}
}
}
die;
}
?>
This script is working but its taking too much time as there are large number of products is there any better to do this.
Please let me know any better solution or any modification required in my current approch