3

Currently our store's configurable products have the short & long descriptions contained within the parent product. The child product description fields are blank. We're setting up a Google Shopping campaign, and need those descriptions copied from the parent product to the child.

I'm attempting this by using a PHP shell script. I've adapted the script I found here. My version is:

<?php
require_once '../app/Mage.php';

Mage::app();
$products = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
    ->addAttributeToFilter('short_description','')
$products->load();

foreach($products as $product) { 
    $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
    foreach($parentIds as $parentId) {
        $parent = Mage::getModel('catalog/product')->load($parentId);
        $product->setShortDescription($parent->getShortDescription());
        $product->save();
        continue;
    }
}

When I run this, I get a php parse error on line 8 $products->load();

  1. Am I on the right track here?
  2. Why am I getting that parse error?

edit: I don't necessarily have to use a shell script either. If there's a better way I'm missing, please share.

1 Answer 1

1

So the solution is much easier than I thought. I'm using the Wyomind Simple Google Shopping extension to automatically generate my Google Shopping product feed. There's a simple syntax for including data from a child product's parent.

Simply change:

{G:DESCRIPTION}

to:

{G:DESCRIPTION parent}

Done!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.